Closures/Value capture: Difference between revisions

added simplified scheme solution
m (omit from Ada deleted)
(added simplified scheme solution)
Line 1,195:
<lang scheme>(1 4 9 16 25 36 49 64 81 100)
81</lang>
 
----
 
Using Scheme [http://srfi.schemers.org/srfi-1/srfi-1.html SRFI 1] ''iota'' procedure can be simplified to:
<lang scheme>
(define list-of-functions (map (lambda (x) (lambda () (* x x))) (iota 0 1 10)))
 
; print the result
(display
(map (lambda (n) (n)) list-of-functions)
(newline)
</lang>
 
=={{header|Scala}}==
Anonymous user