|
|
|
|
|
by Capricorn2481
1114 days ago
|
|
(-> x (* 2) (+ 1) (- 3) (% x))
The part that is confusing if you don't know Clojure is (->). This a thread macro, and it passes "x" through a list of functions.So it basically breaks this down into a list of instructions to do to x. You will multiply it by 2, add 1 to it, take 3 from it, then do the modulus by the original value of x (the value before any of these steps). Clojurists feel like this looks more readable than the alternative, because you have a list of transformations to read left to right, vs this (% (- (+ (* x 2) 1) 3) x)
Which is the most unreadable of them all, to me. |
|
Currying with OOP:
Currying with assignment operators: Naming things instead of Currying: Or aping that in Scheme: