3 ms·
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 p
by dpritchett 13y ago
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"
- minikomi 13y agoIf the function name or docstring is descriptive enough, I'd just go for (defn square-halve-add3-to-string [n] (-> n (#(* % %)) (/ 2.0) (+ 3) str))