by roboguy12 · 10y ago · 0 comments
1 + (2 * 10) - (12 / 3)
is so much easier for me to read to read than (- (+ 1 (* 2 10) (/ 12 3)))
But when working with functions, I much prefer the standard Clojure syntax. (- (+ 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.
f x . g
reads just so much easier than (comp (partial f x) g)