Tim Bradshaw <tfb+google@tfeb.org> wrote:
+---------------
| "Alex Mizrahi" <udode...@users.sourceforge.net> wrote:
| > CL-USER> (loop for fun in
| > (loop for obj in '(1 2 3 4 5)
| > collect (let ((obj obj)) (lambda () obj)))
| > collect (funcall fun))
| > (1 2 3 4 5)
| >
| > however, i'm not sure that this fix works according to
| > Common Lisp standard.
|
| Yes, this is the right way of doing this.
+---------------
Though it would be a *lot* easier to read if written this way:
> (loop for item in '(1 2 3 4 5)
collect (let ((obj item)) (lambda () obj)))
(#<Interpreted Function "LOOP FOR" {489410B1}>
#<Interpreted Function "LOOP FOR" {48941141}>
#<Interpreted Function "LOOP FOR" {489411D1}>
#<Interpreted Function "LOOP FOR" {48941261}>
#<Interpreted Function "LOOP FOR" {489412F1}>)
> (mapcar 'funcall *)
(1 2 3 4 5)
>
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607