Hi! I'm looking for a more elegant solution of the following task.

for i in rangeA {
    for j in rangeB {
        foo(param, i, j);
    }
    bar();
}

I need to translate this to factor.

foo(param, y, x) <=> x y param foo

I have a solution:
rangeA rangeB param [ foo ] curry [ swapd [ call ] 2curry each bar ] 2curry
each

For example,
rangeA = { "a" "b" "c" }
rangeB = { "1" "2" "3" }
param = " "
foo = append append write ;
bar = "" print ;

{ "a" "b" "c" } { "1" "2" "3" }  " " [ append append write ] curry [ swapd [
call ] 2curry each "" print ] 2curry each

Result is :
1a 2a 3a
1b 2b 3b
1c 2c 3c

I think my solution is bloated with partial applications. Maybe someone can
provide a better way to solve this task.

Cheers,
    Ark. Rost
------------------------------------------------------------------------------
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

Reply via email to