functional programming in Maxima



That's good'ol dynamic scope for you.

The inner lambda is returned with no reference to its lexical environment.

Lexical scope would be nice in many ways ... But as we've discussed
over the years, it might not mix well with other aspects of Maxima
evaluation.

          -s

On 3/4/10, Richard Fateman <fateman at cs.berkeley.edu> wrote:
> I tried
> F:lambda([y],lambda([x],x^2+y));
>
> F(3)(4)
>
> expecting to get 4^2+3 or 19.
>
> Instead I got y+16.
>
> Is this expected?
>
> F:lambda([y],buildq([y:y],lambda([x],x^2+y)))
>
>  works to give 19...
>
> RJF
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>

-- 
Sent from my mobile device