William James
12/3/2015 8:10:00 PM
WJ wrote:
> >
> > Then suppose you later need the loop/map to collect some of the values
> > under certain conditions. You might have
> >
> > (loop for x in (get-list)
> > for i from 0
> > do (format t "~A - ~A~%" i x)
> > if (test x)
> > collect (foo x))
> >
Ruby:
get_list.each_with_index.
grep->((x,i)){puts "#{ i } - #{ x }"; test x}{|x,_| foo x}
Testing:
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"]
Ocaml:
open List;;
open Printf;;
let accum = ref [] in
iteri (fun i x -> printf "%d - %d\n" i x;
if test x then accum := foo x :: !accum)
(get_list ()) ;
rev !accum ;;
--
I think that we have to remember that the real activists who are doing this are
motivated not by love for humanity, not by love for America or anything else;
they are motivated by hatred for the traditional people and culture of America.
They are motivated by hatred toward the traditional people and culture of the
European countries. --- www.redicecreations.com/radio/2014/09/RIR-140929.php