Hacker News new | past | comments | ask | show | jobs | submit login

I wonder, does #(* %1) do anything sensible?



Clojure's * can accept any number of arguments, including zero (returns 1 in this case), one (acts as identity function on numbers) or more than two (returns the product of all arguments). This helps to simplify arithmetic expressions in some cases (e. g. polynominals) and allows to calculate a sum or product of any sequence, including empty one, using (reduce * xs)


> I wonder, does #(* %1) do anything sensible?

It's a 1-argument function, so applying it to 2 arguments would give an error. Minus the arity error, 1-argument * is an identity.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: