strangeness: constructing subscripted functions



I think your patch will break a few tests in the testsuite; maybe something
like

 (%i1) p[n](x):= diff(x^n,x,n)$

 (%i2) p[2](a+1);
 (%o2) 2

Redefine constlam as suggested. Try again:

 (%i4) q[n](x):= diff(x^n,x,n)$
 (%i5) q[2](a+1);
  Non-variable 2nd argument to diff: a+1

Of course, without the patch

 (%i8) h(n,x):= diff(x^n,x,n)$
 (%i9) h(2,a+1);
 Non-variable 2nd argument to diff: a+1

Where does the user-documentation explain why (%o2) and (%o9) are
different?

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>Here is some strange behavior, reported by a user.
>
>foo [x] (y) := x * length (y);
>foo [3];
> => error: length called on atomic symbol y
>
>Instead maybe I'd hope to see lambda([y], 3 * length(y)) .
>
>PS. Here is a patch to put the above proposal into action.
>
>--- src/mlisp.lisp      21 Jun 2008 21:14:06 -0000      1.66
>+++ src/mlisp.lisp      15 Jul 2008 03:09:39 -0000
>@@ -1899,7 +1899,7 @@
> (defun constlam (x &aux (lam x))
>   (if aexprp
>       `(,(car lam) ,(cadr lam) ,@(mbinding ((mparams (cadr lam)))
>-                                          (mapcar #'meval (cddr lam))))
>+                                          (mapcar #'mevalatoms (cddr
>lam))))
>
>       lam))
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima