substitutions within a function



On 1/10/07, Daniel Lakeland <dlakelan at street-artists.org> wrote:

> I know there's something I don't understand about maxima
> evaluation... I have an expression "fma_steady" and I want to create a
> function which has 2 parameters which returns the result of
> substituting those parameters into the expression fma_steady.

Not sure what you want to accomplish but here is an idea.

make_lambda (expr, L) := buildq ([expr, L], lambda (L, expr));

foo : a*x^2 + b*y^2;
F : make_lambda (foo, [x, y]);
  => lambda([x, y], b*y^2 + a*x^2)
G : make_lambda (foo, [a, b]);
  => lambda([a, b], b*y^2 + a*x^2)
F(10, - 2);
  => 4*b + 100*a
G(10, - 2);
  => 10*x^2 - 2*y^2

HTH
Robert