Higher-order functions: Difference between revisions

Content deleted Content added
m →‎{{header|REXX}}: removed superflous blanks. -- ~~~~
Line 1,573:
 
=={{header|REXX}}==
<lang rexx>/*pass a function as a name to a function. */
<lang rexx>
/*pass a function as a name to a function. */
 
n=3735928559
funcName='fib' ; q= 10; call someFunction funcName,q; call tell
Line 1,585 ⟶ 1,583:
say 'done as' d2x(n)"." /*prove that var N still intact.*/
exit
 
 
/*──────────────────────────────────────where the rubber meets the road.*/
someFunction: procedure; arg whatwhat,n; signal value (whatwhat)
say result 'result'
return
 
/*──────────────────────────────────────functions that are on the road. */
cube: return n**3
Line 1,599 ⟶ 1,594:
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'''
</lang>
<pre style="height:25ex;overflow:scroll">
Output:
<pre style="height:25ex;overflow:scroll">
fib(10) = 55
fact(6) = 720