how to calculate all of possible variants of expression?
Subject: how to calculate all of possible variants of expression?
From: praimon
Date: Thu, 19 Jul 2007 10:32:09 -0400
On 7/18/07, Raymond Toy <raymond.toy at ericsson.com> wrote:
> toter at mail.ru wrote:
> > excuse me for my english :)
> >
> > for example I have something like that
> > a:[1,2];
> > b:[3,4];
> >
> > how to do so that c=a*b;
> >
> > must be ?=[3,4,6,8] (?=[1*3=3, 1*4=4, 2*3=6, 2*4=8])
>
> Here is one way:
>
> flatten(map(lambda([x],map(lambda([y],x*y),[3,4])),[1,2]));
>
> There are probably better ways.
>
> Ray
here's another way:
(%i5) flatten(outermap("*",a,b));
(%o5) [3, 4, 6, 8]