Arc Forumnew | comments | leaders | submitlogin
1 point by icemaze 5929 days ago | link | parent

True, but sometimes you want some particular value for those special cases. In case of a sum (reduce add ()) should return 0, which is the (mathematically) "right" result.

Is there a way to know the arity of a function?



1 point by parenthesis 5929 days ago | link

Yes, I suppose the real solution is an optional initial value argument (as in CL reduce)), thus you can provide an appropriate identity value (e.g. 0 in the case of add).

Edit: as simonb has simultaneously given.

-----