title: How can I call recur in an if conditional in Clojure?
body: <p>I'm trying to solve the <em>count a sequence</em> excercise at <a href="http://4clojure.com/problem/22#prob-title" rel="noreferrer">4clojure.com</a>. The excercise is to count the number of elements in a collection without using the <code>count</code> function.</p>
  
  <p>I thought I can do this via recursion, by the usage of <code>rest</code>. If what I get isn't empty, I return <code>1 + recur on the sequence rest returned</code>. The problem is, that I end up getting</p>
  
  <pre><code>java.security.PrivilegedActionException: java.lang.UnsupportedOperationException:
  Can only recur from tail position
  </code></pre>
  
  <p>even though I'm calling <code>recur</code> as the very last statement. </p>
  
  <pre><code>(fn [coll] (let [tail (rest coll)]
               (if (empty tail)
                 1
                 (+ 1 (recur tail)))))
  </code></pre>
  
  <p>Am I missing something?</p>