Closures/Value capture: Difference between revisions

m
→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.)
Line 1,210:
 
=={{header|REXX}}==
<lang rexx>/*REXX pgmprogram has a list of 10ten functions, each returns its invocation (idxindex)² squared.*/
 
do j=1 for 9; ?=random(0, 9) /*invoke random functions 9nine times.*/
interpret 'CALL .'random(0,9)? /*invoke a randomly selected funcfunction. */
end /*j*/ /* [↑] the randomcalled funcfunction has no args*/
 
say 'The tenth invocation of .0 ───► ' .0()
exit /*stick a fork in it, we're all done. */
/*───────────────────────────[Below is the closest thing to anonymous functions in the REXX lang.] */
/*─────────────────────────────────list of 10 functions─────────────────*/
.50: return .(); .61: return .(); .72: return .(); .83: return .(); .94: return .()
/*[Below is the closest thing to anonymous functions in the REXX lang.] */
.05: return .(); .16: return .(); .27: return .(); .38: return .(); .49: return .()
/*──────────────────────────────────────────────────────────────────────────────────────*/
.5:return .(); .6:return .(); .7:return .(); .8:return .(); .9:return .()
.: if symbol('@')=='"LIT'" then @=0 /*handle ◄───handle very 1st invoke*/; @=@+1; return @*@</lang>
/*─────────────────────────────────. function───────────────────────────*/
'''output'''
.: if symbol('@')=='LIT' then @=0 /*handle 1st invoke*/; @=@+1; return @*@</lang>
{{out}}
<pre>
The tenth invocation of .0 ───► 100