 <p>As @leppie points out, the accepted solution does not match your text. I would have thought of the following:</p> <pre><code>(define (iterator start step end) (lambda () (if (&gt;= start end) '() (begin0 start (set! start (+ start step)))))) </code></pre> <p>testing:</p> <pre><code>(define i (iterator 0 2 7)) (i) =&gt; 0 (i) =&gt; 2 (i) =&gt; 4 (i) =&gt; 6 (i) =&gt; '() (i) =&gt; '() </code></pre> <p>Note that I use Racket's <code>begin0</code> form. If your Scheme doesn't have it, you can change to the following:</p> <pre><code>(define (iterator start step end) (lambda () (if (&gt;= start end) '() (let ((res start)) (set! start (+ start step)) res)))) </code></pre>