Jump to content

Closures/Value capture: Difference between revisions

Line 249:
{{out}}
<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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.