Re:On Lisp
by minikomi on Monday August 26, 2013 @10:31AM
(#6277254)
That looks like a good place to use the arrow macro http://clojuredocs.org/clojure_core/clojure.core/-%3E
[ Parent
| on HN ]
Re:On Lisp
by dpritchett on Monday August 26, 2013 @11:10AM
(#6277522)
Yep, that's what the link in my original post was hoping to demonstrate. I find rolling up a few lets one after the other more natural in some other situations.
Re:On Lisp
by dpritchett on Monday August 26, 2013 @11:59AM
(#6277867)
Although I'm second-guessing my let example now. Lets are great for assigning names to your building blocks, but I don't really like using them to obscure my processing flow as above. Perhaps this would be a better compromise:
(defn example [n]
(let [square #(* % %)
halve #(/ % 2.0)
add3 #(+ % 3)]
(-> n square halve add3 str)))
> (example 1)
"3.5"