title: unfold function in scheme
body: <p><strong>Goal:</strong> implement <code>unfold</code> function using only two arguments. </p>
  
  <p><strong>The arguments:</strong></p>
  
  <ul>
  <li>the first argument is f which takes an initial value of some type I and returns nil or a cons pair of two elements (the first of these two is the next element that goes in the list of some type A and the next initial value again of some type I). </li>
  <li>The second argument is an initial value of some type I and the return is a list of items of type A.</li>
  </ul>
  
  <p>This is what I have so far and I am not sure why it is not working: </p>
  
  <pre><code>(define (descending i)
    (if (= i 0)
      (list)
      (cons i (- i 1))))
  
  (define nil (list))
  
  (define (unfold f init)
    (if (eq? (f init) '())
      (list)
      (cons init (unfold f (f init)))))
  
  (unfold (descending 5))
  </code></pre>
  
  <p>should evaluate to</p>
  
  <pre><code>'(5 4 3 2 1)
  </code></pre>
  
  <p>This should be the result but isn't. What am I doing wrong?</p>