array functions



> Is it possible to get this to work?
> h1[k](x):=block(map(print,x))

It is trivial to get that to work since the body doesn't depend on k.
Just quote the body:

   h1[k](x):='block(map(print,x))

But presumably there is some reason you're using an indexed function.  I
can't think of a clean, simple way of doing this, since Maxima doesn't
(currently) support closures, but this way should work:

   h1[k](x):= subst(k,'kval,block([k:kval],...)

then h1[99] returns lambda([x],block([k:99],...).

---------------

Another thing to keep in mind with indexed functions is that h1[i] is
only evaluated ONCE for each particular i.  In fact, this is the main
raison d'etre of indexed functions.

(C1) ww[i](x):=x^(i*p);
                                           i p
(D1)                            ww (x) := x
                                  i
(C2) ww[4](z),p=5;
                                       20
(D2)                                  z

/* OK, no problem so far */

(C3) ww[4](z),p=10;
                                       20
(D3)                                  z

/* ??? Why doesn't it change when p changes? */

(C4) ww[4];
                                            20
(D4)                           LAMBDA([x], x  )

/* Here's the answer: the value of ww[4] was calculated once, in a
context where p=5, and is always x^20, regardless of the value of p in
other contexts. */

/* Let's do things a little differently */

(C5) ww[5](z);
                                      5 p
(D5)                                 z

/* Now we start by evaluating ww[5] in a context where p is unbound */

(C6) ww[5](z),p=5;
                                       25
(D6)                                  z
(C7) ww[5](z),p=10;
                                       50
(D7)                                  z
(C8) ww[5];
                                            5 p
(D8)                           LAMBDA([x], x   )