title: Can this particular recursion be rewritten in a tail-optimized way?
body: <pre><code>phi n 0 = 1
  phi n l = 1 + 1 / phi n (l - 1)
  </code></pre>
  
  <p>Obviously, the last evaluated action <strong>is not</strong> recursive call, thus given implementation indeed throws with a sufficiently large <code>l</code>.</p>
  
  <p>So what's the way (if any) to rewrite recursion such that 1) it remains recursive, 2) becomes tail-optimized? I assume <code>phi n l result</code> would work, however can't redefine accordingly... are there reliable methods/techniques how to tackle down such a problems?</p>