Michael Somos on Mon, 25 Feb 2019 16:17:43 +0100


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

Re: Getting arity of closures


The following code may do what you want:

arity(f)=my(v= Vec(component(f,5)[1])); #select(x->x==",",v)+(v!=[])

It is a bit clunky, but it works. Try arity(arity).

On 2/25/19, Jeroen Demeyer <J.Demeyer@ugent.be> wrote:
> Is there any GP function to determine the arity of a closure? Something
> like that would be useful, for example to specify different behaviour
> when taking a closure as input (like lfuncreate for example).
>
>