Writing recursive functions in Clojure, and what to watch for with the call stack.
A recursive function is just a function that calls itself. In Clojure, the important question is not “can I write recursion?” but “is this recursion safe and readable?”
recur) when you would otherwise risk stack overflow.reduce or sequence functions unless recursion is clearer.Java mental model: many “recursive” problems in Java are solved with loops. In Clojure, the first choice is often sequence transformations, and explicit recursion is reserved for when it improves clarity.
This section helps you write recursion that future readers can trust.