Whats the precise definition of \"tail position\" for recur in clojure. I would think that it would be the last item in a loop S-expression, but in the example below it seem
Just to supplement the excellent answer from Paul above, The Joy of Clojure (ed1) provides a table (Table 7.1) that shows exactly where tail position is in various forms/expressions, which I've reproduced below. Look for where the word "tail" occurs in each form/expression:
|---------------------+-------------------------------------------+---------------| | Form | Tail Position | recur target? | |---------------------+-------------------------------------------+---------------| | fn, defn | (fn [args] expressions tail) | Yes | | loop | (loop [bindings] expressions tail) | Yes | | let, letfn, binding | (let [bindings] expressions tail) | No | | do | (do expressions tail) | No | | if, if-not | (if test then tail else tail) | No | | when, when-not | (when test expressions tail) | No | | cond | (cond test test tail ... :else else tail) | No | | or, and | (or test test ... tail) | No | | case | (case const const tail ... default tail) | No | |---------------------+-------------------------------------------+---------------|