I've been doing some Genetic Programming and I've been separating functions into different function sets based on their arity; it's all rather complex.
I'd like to know if there's a simpler way to to do it. For example, if there's a function that returns the arity of a given function.
Cheers in advance.
For interpreted functions you should be able to use
function-lambda-expression.For compiled functions, alas, this function often returns
nil, so you will have to use an implementation-dependent function (clocc/port/sys.lisp):EDIT: note that arity in CL is not really a number, since Lisp functions can accept optional, rest and keyword arguments in addition to required ones; this is why the above
arglistfunction returns the lambda list of the argument function, not a number.If you are only interested in functions which accept only required parameters, you would need to use something like