splicing list of optional arguments in function call
Subject: splicing list of optional arguments in function call
From: Richard Fateman
Date: Tue, 14 Sep 2004 08:40:03 -0700
I don't know what exactly you are trying to do, but
maybe you can make your life simpler by not trying to
call foo again or using buildq. Use a different function, and one with a
fixed number of arguments. Like
foo(a,b,c,[z]):=
if atom(a) then ....
else if inpart(a,0)="=" then
foo2 (lhs(a)-rhs(a), cons(b,cons(c,z)))
... foo2 always takes 2 arguments, an expression and a list.
... good lick.
You should think twice before using buildq. And then
think twice again. Unless you require unconventional
evaluation of arguments, it is probably a mistake to
use it.
RJF
Albert Reiner wrote:
> Hi,
>
> I have learnt here in the past (thanks!) that one can use an arbitrary
> number of arguments by using [symbol], rather than a symbol itself, as
> the last formal argument. Now I have some function foo with optional
> arguments, and if the non-optional first argument is an equation I
> want to call foo again with the same arguments, but substituting the
> difference of left and right hand sides of the equation as the first
> argument. Currently I have something like
>
> foo(a,b,c,[z]) :=
> if inpart(a,0) = "="
> then
> buildq([a: inpart(a,1)-inpart(a,2), b, c, z],
> lambda([], foo(a,b,c,splice(z)))) ()
> else
> [ a, b, c, z ] $
>
> Where I need the splice(z) to avoid getting an extra list around the
> optional arguments, and I need the buildq to be able to use splice,
> and I need the lambda([],...)() to evaluate the call, rather than
> getting an unevaluated foo(...) expression. This seems to work, but
> is there a simpler way?
>
> Thanks in advance,
>
> Albert.
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima