How to set the default argument value of a function.



There is no built-in functionality for this, but you can program it
yourself easily enough:

      f1(a,[b]) := ( if b=[] then b:[1,2],
                     ...rest of function...)

or

      f1(a,[b]) := ( if length(b)=0 then b:[1,2],
                     ...rest of function...)



On Sun, Dec 1, 2013 at 7:01 AM, - <mleoking at gmail.com> wrote:

>
> I know it is possible to define a function with variable number of
> arguments by reading the manual here:
> http://maxima.sourceforge.net/docs/manual/en/maxima_36.html.
>
> However, I did not find how to define the default values of the arguments
> of a function.
>
> For example,
>
> f1(a,[b]):=(a+b[1]+b[2]);
>
> f1(3);
>
> I want b[1] and b[2] to be equal to 1 and 2 by default when they are
> omitted when calling f1.
>
> Help would be appreciated.
>
>
> Leo
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>