[Paul RIVIER , Mon, 05 Dec 2005 15:47:01 +0000]:
> I am looking for a way to assign Fm elements to U elements,
> element-per-elements.
> I mean that at the end of the process, typing U1y; should return cos(x)
> for exemple, or U2x; should return sin(x)^2.
Here is the simplest way I have come up with, but I am sure it should
be possible much simpler. The problem is that ":" cannot be mapped,
in which case you would just write map(":", U, Fm). Instead, the
following works:
(%i12) U:MATRIX([U1x],[U1y],[U2x],[U2y]);
[ U1x ]
[ ]
[ U1y ]
(%o12) [ ]
[ U2x ]
[ ]
[ U2y ]
(%i13) Fm:MATRIX([SIN(x)],[COS(x)],[SIN(x)^2],[ATAN(x)]);
[ SIN(x) ]
[ ]
[ COS(x) ]
(%o13) [ ]
[ 2 ]
[ SIN (x) ]
[ ]
[ ATAN(x) ]
(%i15) map(lambda([l,v], buildq([l:inpart(l,1),v:inpart(v,1)],
lambda([],l : v))()),
U, Fm);
2
(%o15) MATRIX(SIN(x), COS(x), SIN (x), ATAN(x))
(%i16) U2y;
(%o16) ATAN(x)
(%i17)
(%i17) U2x;
2
(%o17) SIN (x)
However, the buildq([...], lambda([]))() idiom for forcing evaluation
is not really pretty.
HTH,
Albert.