Recursion - sorokod/Clojure-Notes GitHub Wiki
Your standard size of a sequence. Second version uses recur and is a tail recursive. The pattern is (loop [x x-initial-value, y y-initial-value] (do-something-with x y)). Initially loop binds the variables in the even positions to the values in the odd positions.
(defn size [v]
(if (empty? v)
0
(inc (size (rest v)))))
(defn size [v]
(loop [l v, ctr 0]
(if (empty? l)
ctr
(recur (rest l) (inc ctr)))))