Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #44057
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Unfeasible? |
| Date | 2015-12-03 20:22 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n3q89d$9d1$1@dont-email.me> (permalink) |
One has a function "get_list" that produces a list.
He has another function "test" that determines whether
a member of the list passes muster.
He has a function "foo" that is used to transform
an element of the list.
The task is to iterate through the list while
printing each element with its index and collecting
the transformations of the elements that fit the bill.
Wouldn't this be painful in the Toy Language (ANS Forth)?
Ruby:
def get_list; ('aa'..'zz').step(36).to_a ; end
def test s; s == s.reverse ; end
def foo x; x.upcase ; end
get_list.each_with_index.
grep->((x,i)){printf "%2d - %s\n", i, x; test x}{|x,_| foo x}
0 - aa
1 - bk
2 - cu
3 - ee
4 - fo
5 - gy
6 - ii
7 - js
8 - lc
9 - mm
10 - nw
11 - pg
12 - qq
13 - sa
14 - tk
15 - uu
16 - we
17 - xo
18 - yy
==>["AA", "EE", "II", "MM", "QQ", "UU", "YY"]
--
I would hesitate to describe America as a nation at all in 1997, because it is
something very different: a polyethnic federation administered by a single
ruling class.... [T]he accumulated rot in America has now reached a point
where the pillars of society itself are failing. --- Ambrose Evans-Pritchard
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Unfeasible? "WJ" <w_a_x_man@yahoo.com> - 2015-12-03 20:22 +0000
Re: Unfeasible? Julian Fondren <julian.fondren@gmail.com> - 2015-12-03 16:17 -0800
Re: Unfeasible? Paul Rubin <no.email@nospam.invalid> - 2015-12-03 17:47 -0800
Re: Unfeasible? Julian Fondren <julian.fondren@gmail.com> - 2015-12-03 19:48 -0800
Re: Unfeasible? Paul Rubin <no.email@nospam.invalid> - 2015-12-04 21:13 -0800
Re: Unfeasible? Julian Fondren <julian.fondren@gmail.com> - 2015-12-04 23:48 -0800
Re: Unfeasible? Paul Rubin <no.email@nospam.invalid> - 2015-12-05 00:11 -0800
Re: Unfeasible? Julian Fondren <julian.fondren@gmail.com> - 2015-12-05 00:35 -0800
Re: Unfeasible? Paul Rubin <no.email@nospam.invalid> - 2015-12-05 00:40 -0800
Re: Unfeasible? hughaguilar96@gmail.com - 2015-12-04 20:53 -0800
Was: Unfeasible? Is: Infeasible rickman <gnuarm@gmail.com> - 2015-12-03 19:18 -0500
Re: Unfeasible? "WJ" <w_a_x_man@yahoo.com> - 2015-12-04 01:11 +0000
Re: Unfeasible? rickman <gnuarm@gmail.com> - 2015-12-03 20:50 -0500
Re: Unfeasible? Bernd Paysan <bernd.paysan@gmx.de> - 2015-12-04 03:23 +0100
Re: Unfeasible? "WJ" <w_a_x_man@yahoo.com> - 2015-12-04 05:55 +0000
Re: Unfeasible? Melzzzzz <mel@zzzzz.com> - 2015-12-06 01:01 +0100
csiph-web