title: For-loop in scheme
body: <p>I want to define a for-n function in scheme that takes 3 parameters, start and stop are integers and fn is a function. I want the for-n function to call fn with start then start+1 ... and in the end with stop.<br>
  Also I want to store all the values fn returns in a list. Please help me get started. I am an experienced programmer but have just starting learning scheme. </p>
  
  <p>This is the function definition I got:</p>
  
  <p>[edit]</p>
  
  <pre><code>    (define (fn a)
          a
       )
  
      (define (for-n start stop fn)
        (cond
          ((&gt; start stop) (quote ()))
          ((= start stop) (list(fn start)))
          (else (list(for-n (+ start 1) stop fn))) 
         )
       )
  
  
      &gt; (for-n 3 5 fn)
      (list (list (list 5)))
  </code></pre>
  
  <p>When (for-n 3 5 fn) is called, I want it to return
  (3 4 5), what am I doing wrong?</p>
  
  <p>[edit-2]<br>
  Thanks for the help everyone. I got function working now. Here is what I got:  </p>
  
  <pre><code>    (define (for-n start stop fn)
        (cond
          ((&gt; start stop) (quote ()))
          ((= start stop) (list(fn start)))
          (else (cons (fn start) (for-n (+ start 1) stop fn))) 
         )
       )
  </code></pre>