[Openmcl-devel] Closures

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Sun Apr 20 04:34:01 PDT 2014


Hi

Can someone explain the following:

? (let ((fn nil)) (dotimes (k 2) (push (lambda () (print k)) fn)) (dolist
(f fn) (funcall f)))

2
2
NIL
? (let ((fn nil)) (dotimes (k 2) (let ((r k)) (push (lambda () (print r))
fn))) (dolist (f fn) (funcall f)))

1
0
NIL
? (defvar r 10)
R
? (let ((fn nil)) (dotimes (k 2) (let ((r k)) (push (lambda () (print r))
fn))) (dolist (f fn) (funcall f)))

10     ?????
10     ?????
NIL
?

Kind regards
Taoufik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140420/1c0294d4/attachment.htm>


More information about the Openmcl-devel mailing list