Use Clojure's explicit recur form for stack-safe tail-position loops, and understand when ordinary recursion, reduce, or sequence functions are clearer.
Plain recursion uses the call stack. If you recursively call yourself for each element of a large collection, you can blow the stack.
Clojure provides recur as an explicit, safe way to express tail recursion. When you use recur in the correct position, it compiles to a loop without growing the call stack.
recur can only appear in tail position (the final action).recur can target the nearest loop or the current function.Java mental model:
recuris the closest equivalent to awhileloop, but expressed in a functional style with explicit state variables.