loop special form is not like a for loop.
The usage of
loop is the same as the
loop sets a recursion point.
The recursion point is designed to use with
loop is always used with
To make a loop happen, the number of arguments (arity) specified for
recur’s must coincide with the number of bindings for
loop. That way,
recur goes back to
The syntax is:
(loop [bindings*] exprs*)
Compare the example above with the one in
For a loop exercise, let’s think about how to calculate the sum of a geometric series (http://en.wikipedia.org/wiki/Geometric_series. A well-known geometric series is 1/2 + 1/4 + 1/8 + 1/16 + …., which converges to 1.
Clojure.org, Special Forms, loop
Introduction to Clojure, Looping and Recursion
Clojure from the ground up: macros, Recursion
Clojure for the Brave and True, Do Things, 4.3. loop