John Benediktsson <mrj...@gmail.com> writes: > On Sun, Aug 21, 2011 at 12:49 PM, Arkady Rost <arkr...@gmail.com> wrote: >> for i in rangeA { >> for j in rangeB { >> foo(param, i, j); >> } >> bar(); >> } > This works for your particular task: > > { "1" "2" "3" } [ > { "a" "b" "c" } [ append ] with map " " join print > ] each
Just in case you don't really need to do the "bar()" bit each loop, you might also consider product-each from sequences.product. The first three words below are equivalent to what John wrote (but have worse names). The last word is slightly different, but might be much simpler if you don't really need to run bar() *between* each iteration across rangeB. Rupert USING: sequences sequences.product io ; : with-second ( seq sec -- ) [ " " append append write ] curry each nl ; : do-all ( seq1 seq2 -- ) [ with-second ] with each ; : example-1 ( -- ) { "a" "b" "c" } { "1" "2" "3" } do-all ; : example-2 ( -- ) { { "a" "b" "c" } { "1" "2" "3" } } [ first2 append print ] product-each ; Gives: ( scratchpad ) example-2 a1 b1 c1 a2 b2 c2 a3 b3 c3
pgpbidWwJDrDe.pgp
Description: PGP signature
------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk