Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Clojure provides a number of useful imperative looping
constructs, including doseq and
dotimes, all of which are built upon
recur. recur transfers control to the local-most
loop head without consuming stack space, which is
defined either by loop or a function.
Let’s take a look at a very simple countdown loop:
(loop [x 5](if (neg? x) x
(recur (dec x))))
;= -1