Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20174
| From | "Charles Childers" <crc@retroforth.org> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Filtering |
| Date | 2013-03-02 11:18 -0500 |
| Organization | ForthWorks |
| Message-ID | <op.wtbt9eof6ef20b@denney-2466a6df> (permalink) |
| References | <kgsasr0ibq@enews6.newsguy.com> |
On Sat, 02 Mar 2013 02:48:43 -0500, WJ <w_a_x_man@yahoo.com> wrote:
> Given a sequence of numbers, keep those that are odd and
> multiply them by 100.
>
> Factor:
>
>
> USE: sequences.extras
>
> { 1 1 2 3 5 8 13 21 } [ odd? ] [ 100 * ] filter-map
> { 100 100 300 500 1300 2100 }
Parable:
[ #1 #1 #2 #3 #5 #8 #13 #21 ] array-from-quote
[ odd? ] array-filter [ #10 * ] array-map
Retro:
needs array'
needs math'
with| array' math' |
create results 100 allot
new{ 1 1 2 3 5 8 13 21 }
[ dup odd? [ 100 * @results results + 1+ ! results ++ ] ifTrue ] apply
results display
-- crc
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Filtering "WJ" <w_a_x_man@yahoo.com> - 2013-03-02 07:48 +0000
Re: Filtering mhx@iae.nl (Marcel Hendrix) - 2013-03-02 11:17 +0200
Re: Filtering "Charles Childers" <crc@retroforth.org> - 2013-03-02 11:18 -0500
Re: Filtering "A. K." <akk@nospam.org> - 2013-03-02 17:55 +0100
Re: Filtering Marc Olschok <nobody@nowhere.invalid> - 2013-03-03 22:11 +0000
csiph-web