Re:Is Clojure dying, and what has Ruby got to do with it?
by bshimmin on Thursday May 25, 2017 @06:09PM
(#14420549)
For your second example, your JavaScript is wrong. Let's compare the ES2015 JavaScript:
...against the Clojure:
Not a lot in it, really, is there?
[ Parent
| on HN ]
Re:Is Clojure dying, and what has Ruby got to do with it?
by dragandj on Thursday May 25, 2017 @06:43PM
(#14420725)
The clojure example is really (* 6 4) since * is already a function, not an operator as in most languages.
On the other hand, you can trivially create a macro that would implement the exact es2015 syntax (or at least a very close match), but why would anyone do this?
Re:Is Clojure dying, and what has Ruby got to do with it?
by lilactown on Thursday May 25, 2017 @06:37PM
(#14420698)
If we're golfing...
(#(* %1 %2) 6 4)
Re:Is Clojure dying, and what has Ruby got to do with it?
by smnplk on Thursday May 25, 2017 @09:13PM
(#14421421)
And a bit shorter version...
24
;)
Re:Is Clojure dying, and what has Ruby got to do with it?
by mrkgnao on Thursday May 25, 2017 @11:42PM
(#14421839)
I wonder, does #(* %1) do anything sensible?
Re:Is Clojure dying, and what has Ruby got to do with it?
by latte on Friday May 26, 2017 @07:31AM
(#14423310)
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)