Higher-order functions: Difference between revisions

m
→‎{{header|REXX}}: added a comment, aligned some statements, added whitespace, re-did subroutine fence. -- ~~~~
(adding maxima)
m (→‎{{header|REXX}}: added a comment, aligned some statements, added whitespace, re-did subroutine fence. -- ~~~~)
Line 1,625:
 
=={{header|REXX}}==
<lang rexx>/*REXX program passesdemonstrates passing a function as a name to a function. */
n=3735928559
funcName='fib' ; q= 10; call someFunction funcName,q; call tell
Line 1,633:
funcName='reverse'; q=721; call someFunction funcName,q; call tell
say '~~~~~~~~~'
say 'done as' d2x(n)"." /*prove that var N still intact. */
exit /*stick a fork in it, we're done.*/
exit
 
/*──────────────────────────────────────where the rubber meets the road.*/
/*──────────────────────────────────subroutines─────────────────────────*/
someFunction: procedure; arg whatwhat,n; signal value (whatwhat)
say result 'result'
return
return
/*──────────────────────────────────────functions that are on the road. */
cube: return n**3
square: return n**2
reverse: return 'REVERSE'(n)
fact: !=1; do j=2 to n; !=!*j; end; return !
tell: say right(funcName'('q") = ",20)result; return
fib: if n==0 then return n; if n==1 then return n; _=0; a=0; b=1
do j=2 to n; _=a+b; a=b; b=_; end; return _</lang>
'''output'''
<pre style="overflow:scroll">