2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,25 +1,25 @@
/*REXX program calculates and displays some values for the Ackermann function.*/
/* ╔════════════════════════════════════════════════════════════════════════╗
Note: the Ackermann function (as implemented here) utilizes deep
recursive and is limited by the largest number that can have
"1" (unity) added to a number (successfully and accurately).
*/
/*REXX program calculates and displays some values for the Ackermann function. */
/*╔════════════════════════════════════════════════════════════════════════╗
Note: the Ackermann function (as implemented here) utilizes deep
recursive and is limited by the largest number that can have
"1" (unity) added to a number (successfully and accurately).
*/
high=24
do j=0 to 3; say
do k=0 to high%(max(1,j))
call Ackermann_tell j,k
do j=0 to 3; say
do k=0 to high % (max(1, j))
call tell_Ack j, k
end /*k*/
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────ACKERMANN_TELL subroutine─────────────────*/
ackermann_tell: parse arg mm,nn; calls=0 /*display an echo message. */
#=right(nn,length(high))
say 'Ackermann('mm","#')='right(ackermann(mm,nn),high),
left('',12) 'calls='right(calls,high)
return
/*──────────────────────────────────ACKERMANN subroutine──────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function.*/
parse arg m,n; calls=calls+1
if m==0 then return n+1
if n==0 then return ackermann(m-1,1)
return ackermann(m-1,ackermann(m,n-1))
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell_Ack: parse arg mm,nn; calls=0 /*display an echo message to terminal. */
#=right(nn,length(high))
say 'Ackermann('mm", "#')='right(ackermann(mm, nn), high),
left('', 12) 'calls='right(calls, high)
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function. */
parse arg m,n; calls=calls+1
if m==0 then return n+1
if n==0 then return ackermann(m-1, 1)
return ackermann(m-1, ackermann(m, n-1) )

View file

@ -1,21 +1,21 @@
/*REXX program calculates and displays some values for the Ackermann function.*/
/*REXX program calculates and displays some values for the Ackermann function. */
high=24
do j=0 to 3; say
do k=0 to high%(max(1,j))
call Ackermann_tell j,k
do j=0 to 3; say
do k=0 to high % (max(1, j))
call tell_Ack j, k
end /*k*/
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────ACKERMANN_TELL subroutine─────────────────*/
ackermann_tell: parse arg mm,nn; calls=0 /*display an echo message.*/
#=right(nn,length(high))
say 'Ackermann('mm","#')='right(ackermann(mm,nn),high),
left('',12) 'calls='right(calls,high)
return
/*──────────────────────────────────ACKERMANN subroutine──────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function.*/
parse arg m,n; calls=calls+1
if m==0 then return n+1
if n==0 then return ackermann(m-1,1)
if m==2 then return n*2+3
return ackermann(m-1,ackermann(m,n-1))
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell_Ack: parse arg mm,nn; calls=0 /*display an echo message to terminal. */
#=right(nn,length(high))
say 'Ackermann('mm", "#')='right(ackermann(mm, nn), high),
left('', 12) 'calls='right(calls, high)
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function. */
parse arg m,n; calls=calls+1
if m==0 then return n + 1
if n==0 then return ackermann(m-1, 1)
if m==2 then return n + 3 + n
return ackermann(m-1, ackermann(m, n-1) )

View file

@ -1,36 +1,36 @@
/*REXX program calculates and displays some values for the Ackermann function.*/
/*REXX program calculates and displays some values for the Ackermann function. */
numeric digits 100 /*use up to 100 decimal digit integers.*/
/*╔═════════════════════════════════════════════════════════════╗
When REXX raises a number to an integer power (via the **
operator, the power can be positive, zero, or negative).
Ackermann(5,1) is a bit impractical to calculate.
*/
high=24
numeric digits 100 /*have REXX to use up to 100 digit integers.*/
/*When REXX raises a number to a power (via */
/* the ** operator), the power must be an */
/* integer (positive, zero, or negative). */
do j=0 to 4; say /*Ackermann(5,1) is a bit impractical to calc.*/
do k=0 to high%(max(1,j))
call Ackermann_tell j,k
if j==4 & k==2 then leave /*there's no sense in going overboard. */
end /*k*/
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────ACKERMANN_TELL subroutine─────────────────*/
ackermann_tell: parse arg mm,nn; calls=0 /*display an echo message.*/
#=right(nn,length(high))
say 'Ackermann('mm","#')='right(ackermann(mm,nn),high),
left('',12) 'calls='right(calls,high)
return
/*──────────────────────────────────ACKERMANN subroutine──────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function.*/
parse arg m,n; calls=calls+1
if m==0 then return n+1
if m==1 then return n+2
if m==2 then return n+n+3
if m==3 then return 2**(n+3)-3
if m==4 then do; a=2 /* [↓] Ugh! ··· and more ughs. */
do (n+3)-1 /*This is where the heavy lifting is. */
a=2**a
end
return a-3
end
if n==0 then return ackermann(m-1,1)
return ackermann(m-1,ackermann(m,n-1))
do j=0 to 4; say
do k=0 to high % (max(1, j))
call tell_Ack j, k
if j==4 & k==2 then leave /*there's no sense in going overboard. */
end /*k*/
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell_Ack: parse arg mm,nn; calls=0 /*display an echo message to terminal. */
#=right(nn,length(high))
say 'Ackermann('mm", "#')='right(ackermann(mm, nn), high),
left('', 12) 'calls='right(calls, high)
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
ackermann: procedure expose calls /*compute value of Ackermann function. */
parse arg m,n; calls=calls+1
if m==0 then return n + 1
if m==1 then return n + 2
if m==2 then return n + 3 + n
if m==3 then return 2**(n+3) - 3
if m==4 then do; #=2 /* [↓] Ugh! ··· and still more ughs.*/
do (n+3)-1 /*This is where the heavy lifting is. */
#=2**#
end
return #-3
end
if n==0 then return ackermann(m-1, 1)
return ackermann(m-1, ackermann(m, n-1) )