title: Creating an iterative function in SML
body: <p>I've been stuck on this problem for a while now, and can't think of how to solve it. </p>
  
  <blockquote>
    <p>Consider the following function f : N → N . </p>
    
    <p>f(0) = 2, f(1) = 0, f(2) = 3, </p>
    
    <p>f(n) = 3f(n-3) + 2f(n-2) - f(n-1) for n≥3. </p>
    
    <p>Define an iterative version of f. </p>
  </blockquote>
  
  <p>I know my solution should look something like this</p>
  
  <pre><code>fun myFun 0 = 2
  |   myFun 1 = 0
  |   myFun 2 = 3
  |   myFun n = 
         let
          (* code *)
         in
           funHelp(3,2,0,n)
         end ;
  </code></pre>
  
  <p>I know iterative functions are only suppose to use one recursive call, while letting the arguments do all the work. I can't figure out how to do it with this problem, though! Any help would be much appreciated!</p>