2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,20 +1,18 @@
|
|||
/*REXX program demonstrates passing a function as a name to another function. */
|
||||
n=3735928559
|
||||
funcName = 'fib' ; q= 10; call someFunk funcName, q; call tell
|
||||
funcName = 'fact' ; q= 6; call someFunk funcName, q; call tell
|
||||
funcName = 'square' ; q= 13; call someFunk funcName, q; call tell
|
||||
funcName = 'cube' ; q= 3; call someFunk funcName, q; call tell
|
||||
q=721; call someFunk 'reverse',q; call tell
|
||||
say copies('═', 30) /*display a nice separator fence */
|
||||
say 'done as' d2x(n)"." /*prove that variable N is still intact*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────one─liner subroutines─────────────────────*/
|
||||
/*REXX program demonstrates passing a function (as a name) to another function. */
|
||||
n=3735928559
|
||||
funcName = 'fib' ; q= 10; call someFunk funcName, q; call tell
|
||||
funcName = 'fact' ; q= 6; call someFunk funcName, q; call tell
|
||||
funcName = 'square' ; q= 13; call someFunk funcName, q; call tell
|
||||
funcName = 'cube' ; q= 3; call someFunk funcName, q; call tell
|
||||
q=721; call someFunk 'reverse',q; call tell
|
||||
say copies('═', 30) /*display a nice separator fence */
|
||||
say 'done as' d2x(n). /*prove that variable N is still intact*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
cube: return n**3
|
||||
fact: !=1; do j=2 to n; !=!*j; end; return !
|
||||
fact: !=1; do j=2 to n; !=!*j; end; return !
|
||||
fib: if n<2 then return n; _=0; a=0; b=1; do j=2 to n; _=a+b; a=b; b=_; end; return _
|
||||
reverse: return 'REVERSE'(n)
|
||||
someFunk: procedure; arg ?,n; signal value (?); say result 'result'; return
|
||||
someFunk: procedure; arg ?,n; signal value (?); say result 'result'; return
|
||||
square: return n**2
|
||||
tell: say right(funcName'('q") = ",20) result; return
|
||||
/*────────────────────────────────────────────────────────────────────────────*/
|
||||
fib: if n==0 | n==1 then return n; _=0; a=0; b=1
|
||||
do j=2 to n; _=a+b; a=b; b=_; end; return _
|
||||
tell: say right(funcName'('q") = ",20) result; return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue