While for is somewhat like a loop,
recur is a real loop in Clojure.
recur represents such a remarkable idea that we might even say, “this is Clojure.”
If you have a programming background, you may have heard of tail recursion,
which is a major feature of functional languages.
This recur special form is the one that implements tail recursion.
As the words “tail recursion” indicate, recur must be called in the tail position.
In other words, recur must be the last thing to be evaluated.
Even though we can write code without recur, the use of recur is strongly recommended in Clojure
because of tail-call optimization (TCO).
Compare a recursive sum-up function and a sum-up-with-recur function that uses recur.
The recursive call raises StackOverflowError when summing up to 10000.
On the other hand, recur can sum up even 100000.
This is why tail-call optimization (TCO) works effectively.