3 ms·
If we're golfing... (#(* %1 %2) 6 4)
by lilactown 9y ago
If we're golfing...
(#(* %1 %2) 6 4)
- smnplk 9y agoAnd a bit shorter version... 24 ;)
- mrkgnao 9y agoI wonder, does #(* %1) do anything sensible?
- kbp 9y ago> 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.
- latte 9y agoClojure'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)