different behaviour of lambda() inside and outside functions
Subject: different behaviour of lambda() inside and outside functions
From: andre maute
Date: Thu, 10 May 2007 00:20:18 +0200
I'm relatively new to Maxima,
but is it intended behaviour that lambda behaves differently
if it is called within a function?
I have attached my little test script and
a .txt file containing the output
scaled_u and the last h are different
Andre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parsubst.max
Type: text/x-objcsrc
Size: 445 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20070510/c1752d95/attachment.bin
-------------- next part --------------
Maxima 5.10.0 http://maxima.sourceforge.net
Using Lisp CLISP 2.41 (2006-10-13)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) batch(parsubst.max)
batching /home/seirios/parsubst.max
(%i2) v : [v1, v2]
(%o2) [v1, v2]
2 3
9 v1 9 v1
(%i3) u : (v1 - ----- + -----) v2
2 2
3 2
9 v1 9 v1
(%o3) (----- - ----- + v1) v2
2 2
(%i4) myScaled(v, u) := block([w, h, f], w : [], w : append(w, [2 v ]),
1
w : append(w, [2 v ]), h : u, f : lambda([v1, v2], h), h : apply(f, w),
2
return(h))
(%o4) myScaled(v, u) := block([w, h, f], w : [], w : append(w, [2 v ]),
1
w : append(w, [2 v ]), h : u, f : lambda([v1, v2], h), h : apply(f, w),
2
return(h))
(%i5) scaled_u : myScaled(v, u)
3 2
9 v1 9 v1
(%o5) (----- - ----- + v1) v2
2 2
(%i6) w : []
(%o6) []
(%i7) w : append(w, [2 v ])
1
(%o7) [2 v1]
(%i8) w : append(w, [2 v ])
2
(%o8) [2 v1, 2 v2]
(%i9) h : u
3 2
9 v1 9 v1
(%o9) (----- - ----- + v1) v2
2 2
3 2
9 v1 9 v1
(%i10) f : lambda([v1, v2], (----- - ----- + v1) v2)
2 2
3 2
9 v1 9 v1
(%o10) lambda([v1, v2], (----- - ----- + v1) v2)
2 2
(%i11) h : apply(f, w)
3 2
(%o11) 2 (36 v1 - 18 v1 + 2 v1) v2