Josef Eschgfaeller on Mon, 08 Feb 2016 20:08:32 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: addhelp

Bill Allombert wrote:

> One dirty way to do it in GP is:
> arity(f)=component(f,2)[1]

Many thanks - it seems that one
can obtain in this way also the
implicit arity (see example):

 If I understand well,
component(f,2)[2] is always the
value of the first argument, if this
is optional. Hence for

f (a=10,...)

it is 10. Since I use it for functions
which all have a single argument
which is a vector, whose length L
I know when I write the function,
but not when I apply some other
functions, it suffices to indicate L
as the optional value of the
argument. Artificial example:
implicitarity (f) = component(f,2)[2]

elaborate (f) = {my (n,e);
n=implicitarity(f); e=f([2,5,1]); n*e}

f (v=3) = {my ([x,y,z]=v); x+y+z}

print(t) \\ 24
Josef Eschgfaeller