Closures/Value capture: Difference between revisions

Added Bracmat example
m (→‎{{header|REXX}}: removed OVERFLOW from PRE html tag.)
(Added Bracmat example)
Line 71:
 
Essentially, a function has been constructed for each value to be squared (10 down to 1). The cp operator ensures that we generate a fresh copy of the number to be squared, as well as the code for multiplying, {*}. In the final each loop, we eval each of the constructed functions and output the result.
 
=={{header|Bracmat}}==
<lang bracmat>( -1:?i
& :?funcs
& whl
' ( 1+!i:<10:?i
& !funcs ()'(.$i^2):?funcs
)
& whl'(!funcs:%?func %?funcs&out$(!func$))
);
</lang>
Output:
<pre>0
1
4
9
16
25
36
49
64</pre>
 
=={{header|C}}==
483

edits