Jump to content

Closures/Value capture: Difference between revisions

Latitude language added
(Added Wren)
(Latitude language added)
Line 1,129:
-> 16
</lang>
 
=={{header|Latitude}}==
 
Latitude is particularly well suited to this challenge, as the various iteration constructs actually take method arguments and <i>call</i> them multiple times. Thus, the loop variable is in fact an argument which is already closed over and distinct at each iteration.
 
<lang latitude>functions := 10 times to (Array) map {
takes '[i].
proc { (i) * (i). }.
}.
 
functions visit { println: $1 call. }.</lang>
 
{{Out}}
<pre>0
1
4
9
16
25
36
49
64
81</pre>
 
=={{header|LFE}}==
37

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.