On 04/30/2010 05:57 AM, John Lapeyre wrote:
> On Friday 30 April 2010 03:29:26 Raymond Toy wrote:
>
>> There's function-lambda-expression, but it could return NIL.
>>
> That looks like the best I can do.
>
>
>> This seems like a strange question. You want to call some Lisp
>> function, but you don't know how many arguments it has? Then why are
>> you calling that function to begin with?
>>
>
> It comes up in the Mathematica to Macsyma translator. For instance, in Mma
>
> Mod[10,6]
> 4
>
> Mod[10,6,1] --> error, too many arguments
>
> Apply[Mod[#1,#2]&, {10,6,1}]
> 4
>
> But the Macsyma translation fails when called:
> Apply(lambda( [arg1,arg2], Mod(arg1,arg2) ),[10,6,1]);
>
> This is not documented AFAIK but its what happens. I am testing user code that
> contains the following in the body of a function definition, which asks for
> an array of zeroes:
>
> Array[0*#&,lsf], where lsf is a list of positive integers giving the dimensions of
> the array.
>
> The translator gives this:
>
> Array(lambda( [arg1], (0*arg1) ),lsf))
>
> The anonymous functions want one argument, but lsf could be [2,3] for instance.
> The Mma function silently throws away the superfluous arguments. But Macsyma
> fails with an error. (The user could have even used Array[0&,ls] )
>
> If this behavior only happens with anonymous functions (I
> don't know), I could translate them as
>
> Array(lambda([[args]], f(args[1],...,args[n]), lst));
>
> instead of
>
> Array(lambda([arg1,...,argn], f(arg1,...,argn), lst));
>
> Since I wrote my post I am beginning to suspect it only applies to
> lambda functions, which means I don't need anything like function-lambda-expression.
>
> Thanks,
> John
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
Of course, in maxima there is
listofvars
and you can take the length of the resulting list.
I don't know enough about lisp to know if there is an equivalent.
-sen