On 3/13/10, Edwin Woollett <woollett at charter.net> wrote:
> Mssq3 : block ([msqsum,s1,s2,s3,s4,sL], sL : [1,-1],
> msqsum : 0,
> for s1 in sL do
> for s2 in sL do
> for s3 in sL do
> for s4 in sL do
> msqsum : msqsum + Avsq (factor (emuon (s1,s2,s3,s4)) ),
> factorsum (msqsum));
Well, a "neater" way to do it might replace the do-loops with
an iteration over the result of cartesian_product:
S : {+1, -1};
foo : cartesian_product (S, S, S, S);
bar : maplist (lambda ([L], apply (emucon, L)), foo);
msqsum : apply ("+", map (Avsq, map (factor, bar)));
factorsum (msqsum);
However, my guess is that calls to factor are taking most of the time;
I doubt if the nested loops are slowing down the program.
(maplist always returns a list, while map(..., foo) returns a set
since foo is a set; I'm pretty sure we want bar to be a list.)
Hope this helps!
Robert Dodier