makelist vs create_list



Am 9 Apr 2007 um 14:16 hat Stavros Macrakis geschrieben:

> > Is  expr, x : L   in top level or  ev( expr, x : L )  in programs equivalent
> > to map(lambda([x], expr), L) resp. makelist(expr, x, L) or are there some
> > differences?
> 
> No, ev(expr,x:l) is very roughly equivalent to block([x:l],expr) or
> equivalently lambda([x],expr)(l) or map(lambda([x], [expr]).  It does
> not map over lists.

Thanks for clarification. 

For expressions which only use the basic operations +,-,*,/ and ^ (polynomial expressions) 
the result is the same, due to the definition of arithmetrics with lists, e.g.
(%i1) 4*x^3-x^2+12, x:[1,2,3];
(%o1) 				[15, 40, 111]
(%i2) map( lambda([x], 4*x^3-x^2+12), [1,2,3] );
(%o2) 				[15, 40, 111]

The difference is easily shown with simple expressions like sin(x), e.g.
(%i7) sin(x), x:[1,2,3];
(%o7) 			        sin([1, 2, 3])
(%i8) map( sin, [1,2,3] );
(%o8) 			   [sin(1), sin(2), sin(3)]

Volker