On Sat, Sep 06, 2003 at 05:33:21AM -0500, Lynn Winebarger wrote:
Yeah, but why not get it in the right order:
(define (rep n)
(let loop ((n n)
(k (lambda (v) v)))
(if (= n 0)
(k '())
(loop (- n 1)
(lambda (v)
(k (cons n v))))))
Though reliance on the stack may be/is probably more efficient. All this
version does is allocate the stack in the heap, one disconnected frame at a
time.
... and you can also use an `if', as Lynn has demonstrated above.
Lynn, that's certainly an interesting point, but what's wrong with
just changing the direction in which the counter progresses? :)