Closures/Value capture: Difference between revisions

Content added Content deleted
Line 249: Line 249:
{{out}}
{{out}}
<pre>[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]</pre>
<pre>[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]</pre>

=={{header|Emacs Lisp}}==
Emacs Lisp now has lexical-let, which allows for the capture of variables.
<lang lisp>
(require 'cl)
(mapcar 'funcall
(mapcar (lambda (x)
(lexical-let ((x x))
(lambda () (* x x)))) [1 2 3 4 5 6 7 8 9 10]))
;; => (1 4 9 16 25 36 49 64 81 100)
</lang>


=={{header|Erlang}}==
=={{header|Erlang}}==