As I start week number 5 of my CodeLesson Clojure course and look at programming examples, it is clear to me that when to use recursion or not is a fuzzy science. Most Clojure text books talk about using sequences wherever possible and not even using loop/recur (Clojure’s tail recursion method) let alone recursion without loop/recur. The Clojure Google Groups even called this method low-level while pushing using sequences.

One assignment in particular I found particularly tricky, because it involved how to make change for some number of dollar bills, and the official solution used recursion even without wrapping the sequence inside a lazy-seq function. So, I conclude individual preference and what makes sense will have to prevail concerning Clojure and recursion.

3 responses to “Clojure: To Recurse or Not To Recurse”

Actually I think that in the offical Solution you can use Recursion safely without Lazy-seq because from the Problem Domain it is sure that the Recursion Never gets to be indefintiv so you never get a Stack overflow…I find Recursion a very Natural Tool for these Kinds of Problems …

using lazy-seq is very similar to how you can use recursion in haskell, for me is almost the same sh%$..now..the loop recur I think is very ugly and it seem most to calling a “for” loop in an imperative language..it seems exist only for the jvm limitations but when you use f# it has a better implementation for recursion..really I don’t know which are the difference in the limitation between both plataforms…but I think than loop recursion is really a ugly spot in the clojure face…..