Kent M Pitman <firstname.lastname@example.org> wrote:
| ...i gets bound at the start of the DO and gets assigned at each step.
| You might in your head be thinking DO was just syntactic sugar for a tail
| recursion, but it is not documented that way...
However, those of us who are mainly Scheme programmers (and who lurk here
to pick up general higher-level tips) might indeed make that assumption,
especially since a naive translation to Scheme does give the original
poster's "expected" result:
> (let ((l (do ((i 0 (1+ i))
((= i 3) (reverse r))
(set! r (cons (lambda () i) r)))))
(map (lambda (x) (x)) l))
(0 1 2)
Just another reminder that there are subtle gotchas between Scheme & CL...
Rob Warnock, 7L-551 email@example.com http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673 [New area code!]
2011 N. Shoreline Blvd. FAX: 650-933-4392
Mountain View, CA 94043 PP-ASEL-IA