Anonymous user
Closures/Value capture: Difference between revisions
Updated second D entry, tags
m (omit from Ada) |
(Updated second D entry, tags) |
||
Line 220:
=={{header|D}}==
===Less Functional Version===
<lang d>import std.stdio;
Line 230 ⟶ 231:
writeln(funcs[3]());
}</lang>
{{out}}
<pre>9</pre>
===More
<lang d>import std.stdio, std.range, std.algorithm;
void main() {
auto funcs = iota(10).map!(i => () => i*i)(
}</lang>
{{out}}
<pre>[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]</pre>
|