makelist vs create_list



On 4/10/07, van Nek <van.nek at arcor.de> wrote:
>
> For expressions which only use the basic operations +,-,*,/ and ^
> (polynomial expressions)
> the result is the same, due to the definition of arithmetrics with lists,
> ...
>

Yes, when listarith is true (the default).

And there is another interesting case...:

    x . x, x=[1, 2, 3], listarith:true  =>  14
vs.
    x . x, x=[1, 2, 3], listarith:false  => [1, 2, 3]^^2
vs.
   map( lambda([x], x . x),  [1, 2, 3] )  =>  [1, 4, 9]

Weirdly,
    x^^2, x=[1, 2, 3], listarith:true  =>  [ 14 ]
          (surely a bug)

More fun...

x^^2,x=[[1,2],[3,4]],listarith:false  =>  [[1,2],[3,4]]^^2
x^^2,x=[[1,2],[3,4]],listarith:true  =>  matrix([[10,20]])
map(lambda([x],x^^2),[[1,2],[3,4]]),listarith:false  =>  [[1,2]^^2,[3,4]^^2]
map(lambda([x],x^^2),[[1,2],[3,4]]),listarith:true  =>
[matrix([5]),matrix([25])]

         -s