Browse Clojure Foundations for Java Developers

When to Use Recursion

Use recursion when the problem shape is recursive; use reduce or loop/recur for most loops.

Recursion is a great tool when the problem is naturally recursive: trees, nested structures, parsing, and traversals where “the shape” repeats.

For most everyday iteration over a linear collection, recursion is not the first tool in Clojure.

A simple decision rule

  • If you are transforming a sequence, start with map / filter.
  • If you are accumulating a result, start with reduce.
  • If you need an explicit loop with multiple evolving values, use loop/recur.
  • Use direct recursion when it improves clarity and you can keep it stack-safe (often via recur).

Java mental model: recursion is not the new default. It is one of several iteration tools, and the best choice is the one that keeps the code simplest.

In this section

Revised on Friday, April 24, 2026