You can use procedure-arity .
(procedure-arity expt) ; => 2
Note that when using procedure-arity with variational functions or case-lambda or the like, the results are more complex:
(procedure-arity apply) ; => (arity-at-least 2) (procedure-arity (case-lambda ((x) x) ((xyz) z) ((abcdef . g) g))) ; => `(1 3 ,(arity-at-least 6))
source share