make_lambda function to construct a lambda expression
Subject: make_lambda function to construct a lambda expression
From: Robert Dodier
Date: Thu, 10 May 2007 23:15:59 -0600
Hello,
I wonder what anyone thinks of Maxima having a built-in
function to construct a lambda expression.
Maxima lambda doesn't evaluate its function body.
In various contexts it is useful to evaluate the body.
Let's suppose there is a function named make_lambda.
E.g. a function to construct a lambda to multiply by a.
F (a) := make_lambda (['x], 'x * a);
F (10);
=> lambda ([x], 10 * x)
A function to return a lambda representing one element of
a family of helices.
G (a) := make_lambda (['u], [a * cos ('u), a * sin ('u), 'u]);
G (%pi);
=> lambda ([u], [%pi * cos (u), %pi * sin (u), u])
Here is a possible implementation of make_lambda.
make_lambda (v, expr) := buildq ([v, expr], lambda (v, expr));
make_lambda works more or less like the unapply function in
Maple (if I understand correctly). The idea seems useful;
it's not important to me that a Maxima implementation be
exactly the same.
I suppose interested users could write make_lambda themselves.
However, the whole issue about evaluation is somewhat obscure,
and I can easily believe that a person could understand the idea
of a function to return a function, while being confused about
Maxima's evaluation policies.
This idea was suggested to me by Andre Maute. Thanks Andre.
FWIW
Robert