Jump to content

Closures/Value capture: Difference between revisions

m
→‎{{header|Sidef}}: added a simpler example
m (→‎Delimited Continuations: Spurious parens removed.)
m (→‎{{header|Sidef}}: added a simpler example)
Line 1,244:
=={{header|Sidef}}==
<lang ruby>var f = (
0 ...^ 9 -> map {|i| func(j){i * j} }
);
 
0 ..^ 8 -> each { |j|
say f[j].call(j);
};</lang>
{{out}}
<pre>
Line 1,261:
49
64
</pre>
 
Starting from i=1:
<lang ruby>var f = 10.of { |i|
func(j){i * j}
}
 
9.times { |j|
say f[j-1](j);
}</lang>
{{out}}
<pre>
1
4
9
16
25
36
49
64
81
</pre>
 
2,756

edits

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