September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,11 +1,11 @@
/*REXX program to show anonymous recursion (of a function or subroutine). */
numeric digits 1e6 /*in case the user goes ka-razy. */
numeric digits 1e6 /*in case the user goes ka-razy with X.*/
parse arg x . /*obtain the optional argument from CL.*/
if x=='' | x=="," then x=12 /*Not specified? Then use the default.*/
w=length(x) /*W: used for formatting the output. */
do j=0 to x; jj=right(j, w) /*use the argument as an upper limit.*/
say 'fibonacci('jj") =" fib(j) /*show the Fibonacci sequence: 0 ──► x */
end /*j*/
do j=0 for x+1 /*use the argument as an upper limit.*/
say 'fibonacci('right(j, w)") =" fib(j)
end /*j*/ /* [↑] show Fibonacci sequence: 0 ──► X*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
fib: procedure; parse arg z; if z>=0 then return .(z)

View file

@ -1,12 +1,12 @@
/*REXX program to show anonymous recursion of a function or subroutine with memoization.*/
numeric digits 1e6 /*in case the user goes ka-razy. */
numeric digits 1e6 /*in case the user goes ka-razy with X.*/
parse arg x . /*obtain the optional argument from CL.*/
if x=='' | x=="," then x=12 /*Not specified? Then use the default.*/
@.=.; @.0=0; @.1=1 /*used to implement memoization for FIB*/
w=length(x) /*W: used for formatting the output. */
do j=0 to x; jj=right(j, w) /*use the argument as an upper limit.*/
say 'fibonacci('jj") =" fib(j) /*show the Fibonacci sequence: 0 ──► x */
end /*j*/
do j=0 for x+1 /*use the argument as an upper limit.*/
say 'fibonacci('right(j, w)") =" fib(j)
end /*j*/ /* [↑] show Fibonacci sequence: 0 ──► X*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
fib: procedure expose @.; arg z; if z>=0 then return .(z)