Closures/Value capture: Difference between revisions
Content added Content deleted
(Updated D versions) |
(Fixed output D versions) |
||
Line 180: | Line 180: | ||
}</lang> |
}</lang> |
||
Output: |
Output: |
||
<pre> |
<pre>9</pre> |
||
More functional version |
More functional version: |
||
<lang d>import std.stdio, std.range, std.algorithm; |
<lang d>import std.stdio, std.range, std.algorithm; |
||
Line 188: | Line 188: | ||
writeln(map!q{ a() }(funcs)); |
writeln(map!q{ a() }(funcs)); |
||
}</lang> |
}</lang> |
||
Output: |
|||
<pre>[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |