-
Loop in Clojure
Here’s a way to avoid recursive helper functions… By using loop in Clojure. Sometimes recursive helper functions seem needed, like fibonacci-iter: (I ported this to Clojure from Structure and Interpretation of Computer Programs, licensed CC BY-SA-4.0) That fibonacci-iter helper function is only needed for recursion. For example, the public (defn fibonacci [n] only needs an…
-
When Does A Function Do 1 Thing?
Functions should do one thing. They should do it well. They should do it only. Robert C. Martin in Clean Code You probably agree, but what’s 1 thing? What about the core.clj file’s -main function? That does almost everything in the app. Definitely more than 1 thing, right? Here’s how you know if it does…