how to create list of functions



Hi Glenn,

> I want to create a list of functions so that I can access them via an index.
>
> The following doesn't work, but gives and idea of what I'm trying to do:
>
> f(x):=x;
> g(x):=x^2;
> h(x):=2*x;
>
> a:[f(x),g(x),h(x)];

With these definitions you can write a: [f, g, h];
and then a[2](y + z) => (y + z)^2 as expected.

Maxima recognizes subscripted functions in function
definitions, so you don't need to define f, g, h in order
to define a.

(%i2) a[1](x):=x^2;
(%o2) a[1](x):=x^2
(%i3) a[2](x):=x^3;
(%o3) a[2](x):=x^3
(%i4) a[3](x):=x^4;
(%o4) a[3](x):=x^4

Maxima is keeping the function defns as lambda expressions
in a hash table named "a". The subscript need not be a number.

(%i5) a[3];
(%o5) lambda([x],x^4)
(%i6) a[foo](x):=sin(x);
(%o6) a[foo](x):=sin(x)

(%i7) a[foo](1);
(%o7) sin(1)

Hope this helps,
Robert Dodier