|
|
|
|
|
by malloryerik
3691 days ago
|
|
I believe the parens are off by one in the Clojure example and that it should be: (- (+ 1 (* 2 10)) (/ 12 3)) ;=> 17
I've found the threading operator can help in these cases. (-> (+ 1) (+ (* 2 10) (- (/ 12 3))))
Or, line breaks can clarify: (- (+ 1 (* 2 10))
(/ 12 3))
or at the risk of overdoing it: (-
(+ 1 (* 2 10))
(/ 12 3))
Now I know at first glance that I'm subtracting the results of those two lines from each other.
Indeed the last two might be almost as clear as the infix, and are without any order of operations rules.Also some don't like colored parens but I find them very clarifying. |
|