Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,21 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Ackermann is
function Ackermann (M, N : Natural) return Natural is
begin
if M = 0 then
return N + 1;
elsif N = 0 then
return Ackermann (M - 1, 1);
else
return Ackermann (M - 1, Ackermann (M, N - 1));
end if;
end Ackermann;
begin
for M in 0..3 loop
for N in 0..6 loop
Put (Natural'Image (Ackermann (M, N)));
end loop;
New_Line;
end loop;
end Test_Ackermann;

View file

@ -0,0 +1,39 @@
scope # Ackermann function
proc ackermann( m :: number, n :: number ) :: number
feature reminisce; # create a remember table for this procedure
# it seems the procedure must be global for this statement
return if m = 0 then n + 1
elif m = 1 then n + 2 # expand some cases to avoid more
elif m = 2 then 3 + 2 * n # recursion - as in the Maple
elif m = 3 then 5 + 8 * ( 2 ^ n - 1 ) # Mathematica, etc. samples
elif n = 0 then ackermann( m - 1, 1 )
else ackermann( m - 1, ackermann( m, n - 1 ) )
fi
end;
local constant fmt := seq( " %1.0f", " %2.0f", " %2.0f", " %2.0f"
, " %3.0f", " %3.0f", " %3.0f", " %4.0f"
, " %4.0f", " %4.0f", " %4.0f", " %5.0f"
, " %5.0f", " %5.0f", " %6.0f", " %6.0f"
, " %6.0f", " %7.0f", " %7.0f", " %7.0f"
, " %7.0f", " %7.0f", " %7.0f", " %7.0f"
);
local constant maxN := 20;
printf( " n" );
for n from 0 to maxN do printf( fmt[ n + 1 ], n ) od;
print();
printf( " m+" );
for n from 0 to 18 do printf( "------", n ) od;
print();
for m from 0 to 3 do
printf( "%2d|", m );
for n from 0 to maxN do
printf( fmt[ n + 1 ], ackermann( m, n ) )
od;
print()
od
end

View file

@ -0,0 +1,11 @@
Func Ackermann($m, $n)
If ($m = 0) Then
Return $n+1
Else
If ($n = 0) Then
Return Ackermann($m-1, 1)
Else
return Ackermann($m-1, Ackermann($m, $n-1))
EndIf
EndIf
EndFunc

View file

@ -0,0 +1,18 @@
Global $ackermann[2047][2047] ; Set the size to whatever you want
Func Ackermann($m, $n)
If ($ackermann[$m][$n] <> 0) Then
Return $ackermann[$m][$n]
Else
If ($m = 0) Then
$return = $n + 1
Else
If ($n = 0) Then
$return = Ackermann($m - 1, 1)
Else
$return = Ackermann($m - 1, Ackermann($m, $n - 1))
EndIf
EndIf
$ackermann[$m][$n] = $return
Return $return
EndIf
EndFunc ;==>Ackermann

View file

@ -0,0 +1,32 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Ackermann.
DATA DIVISION.
LINKAGE SECTION.
01 M USAGE UNSIGNED-LONG.
01 N USAGE UNSIGNED-LONG.
01 Return-Val USAGE UNSIGNED-LONG.
PROCEDURE DIVISION USING M N Return-Val.
EVALUATE M ALSO N
WHEN 0 ALSO ANY
ADD 1 TO N GIVING Return-Val
WHEN NOT 0 ALSO 0
SUBTRACT 1 FROM M
CALL "Ackermann" USING BY CONTENT M BY CONTENT 1
BY REFERENCE Return-Val
WHEN NOT 0 ALSO NOT 0
SUBTRACT 1 FROM N
CALL "Ackermann" USING BY CONTENT M BY CONTENT N
BY REFERENCE Return-Val
SUBTRACT 1 FROM M
CALL "Ackermann" USING BY CONTENT M
BY CONTENT Return-Val BY REFERENCE Return-Val
END-EVALUATE
GOBACK
.

View file

@ -0,0 +1,8 @@
proc A(m:int, n:int):int {
if m == 0 then
return n + 1;
else if n == 0 then
return A(m - 1, 1);
else
return A(m - 1, A(m, n - 1));
}

View file

@ -0,0 +1,5 @@
(defun ackermann (m n)
(cond ((zerop m) (1+ n))
((zerop n) (ackermann (1- m) 1))
(t (ackermann (1- m)
(ackermann m (1- n))))))

View file

@ -0,0 +1,16 @@
function ack(atom m, atom n)
if m = 0 then
return n + 1
elsif m > 0 and n = 0 then
return ack(m - 1, 1)
else
return ack(m - 1, ack(m, n - 1))
end if
end function
for i = 0 to 3 do
for j = 0 to 6 do
printf( 1, "%5d", ack( i, j ) )
end for
puts( 1, "\n" )
end for

View file

@ -0,0 +1,12 @@
function ackermann(integer m, integer n)
if m=0 then return n+1
elsif m>0 and n=0 then return ackermann(m-1, 1)
elsif m>0 and n>0 then return ackermann(m-1, ackermann(m,n-1))
else return 0
end if
return 0
end function
? ackermann(0, 0)
? ackermann(3, 4)
? ackermann(3, 10)

View file

@ -0,0 +1,20 @@
pub fn ackermann(m: Int, n: Int) -> Int {
case m, n {
0, n -> n + 1
m, 0 -> ackermann(m - 1, 1)
m, n -> ackermann(m - 1, ackermann(m, n - 1))
}
}
pub fn main() {
echo ackermann(0, 0)
echo ackermann(0, 4)
echo ackermann(1, 0)
echo ackermann(1, 1)
echo ackermann(2, 1)
echo ackermann(2, 2)
echo ackermann(3, 1)
echo ackermann(3, 3)
echo ackermann(4, 0)
echo ackermann(4, 1)
}

View file

@ -0,0 +1,17 @@
//subAck1();
EXPORT Ackermann_function(m,n)
BEGIN
PRINT;
PRINT("Ackermann("+m+","+n+") = "+subAck1(m,n));
END;
subAck1(m,n)
BEGIN
CASE
IF m<0 OR n<0 THEN "m y n deben ser >=0" END;
IF m=0 THEN n+1 END;
IF m>0 AND n=0 THEN subAck1((m-1),1); END;
IF m>0 AND n>0 THEN subAck1((m-1),subAck1(m,(n-1))); END;
DEFAULT RETURN PRINT("ERROR");
END;
END;

View file

@ -0,0 +1,20 @@
class RosettaDemo
{
static public function main()
{
Sys.print(ackermann(3, 4));
}
static function ackermann(m : Int, n : Int)
{
if (m == 0)
{
return n + 1;
}
else if (n == 0)
{
return ackermann(m-1, 1);
}
return ackermann(m-1, ackermann(m, n-1));
}
}

View file

@ -1,4 +1,4 @@
(phixonline)-->
(phixonline)--(notpygments)-->
<span style="color: #008080;">function</span> <span style="color: #000000;">ack</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">m</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">m</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span>

View file

@ -1,4 +1,4 @@
(phixonline)-->
(phixonline)--(notpygments)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Ackermann.exw</span>
<span style="color: #008080;">include</span> <span style="color: #7060A8;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>

View file

@ -0,0 +1,11 @@
function ackermann ([long] $m, [long] $n) {
if ($m -eq 0) {
return $n + 1
}
if ($n -eq 0) {
return (ackermann ($m - 1) 1)
}
return (ackermann ($m - 1) (ackermann $m ($n - 1)))
}

View file

@ -0,0 +1,6 @@
foreach ($m in 0..3) {
foreach ($n in 0..6) {
Write-Host -NoNewline ("{0,5}" -f (ackermann $m $n))
}
Write-Host
}

View file

@ -0,0 +1,14 @@
function Get-Ackermann ([int64]$m, [int64]$n)
{
if ($m -eq 0)
{
return $n + 1
}
if ($n -eq 0)
{
return Get-Ackermann ($m - 1) 1
}
return (Get-Ackermann ($m - 1) (Get-Ackermann $m ($n - 1)))
}

View file

@ -0,0 +1,3 @@
$ackermann = 0..3 | ForEach-Object {$m = $_; 0..6 | ForEach-Object {Get-Ackermann $m $_}}
$ackermann | Format-Wide {"{0,3}" -f $_} -Column 7 -Force

View file

@ -0,0 +1,83 @@
-- 27 Oct 2025
include Setting
numeric digits 310000
say 'ACKERMANN FUNCTION'
say version
say
call Ackermann1
call Ackermann2
exit
Ackermann1:
procedure expose glob.
say 'Using recursion...'
do i=0 to 3
do j=0 to 10
say 'Ackermann('i','j')' '=' Acker1(i,j) Elaps('r')'s'
end
end
say
return
Acker1:
procedure
arg xx,yy
select
when xx = 0 then
return yy+1
when yy = 0 then
return Acker1(xx-1,1)
otherwise
return Acker1(xx-1,Acker1(xx,yy-1))
end
Ackermann2:
procedure expose glob.
say 'Using closed formulas...'
do i=0 to 3
do j=0 to 10
say 'Ackermann('i','j')' '=' Acker2(i,j) Elaps('r')'s'
end
end
say 'Ackermann(3,100) =' Acker2(3,100) Elaps('r')'s'
say 'Ackermann(3,1000) has' Length(Acker2(3,1000)) 'digits' Elaps('r')'s'
say 'Ackermann(3,10000) has' Length(Acker2(3,10000)) 'digits' Elaps('r')'s'
say 'Ackermann(3,100000) has' Length(Acker2(3,100000)) 'digits' Elaps('r')'s'
say 'Ackermann(3,1000000) has' Length(Acker2(3,1000000)) 'digits' Elaps('r')'s'
say 'Ackermann(4,0) =' Acker2(4,0) Elaps('r')'s'
say 'Ackermann(4,1) =' Acker2(4,1) Elaps('r')'s'
say 'Ackermann(4,2) has' Length(Acker2(4,2)) 'digits' Elaps('r')'s'
return
Acker2:
procedure
arg xx,yy
select
when xx=0 then
rr=yy+1
when xx=1 then
rr=yy+2
when xx=2 then
rr=yy+yy+3
when xx=3 then
rr=2**(yy+3)-3
when xx=4 then
select
when yy=0 then
rr=2**(2**2)-3
when yy=1 then
rr=2**(2**(2**2))-3
when yy=2 then
rr=2**(2**(2**(2**2)))-3
otherwise
rr=0
end
otherwise
rr=0
end
return rr
include Abend
-- Elaps
include Timer

View file

@ -0,0 +1,15 @@
let _m = Sys.argv[2]
let _n = Sys.argv[3]
let m = int_of_string(_m)
let n = int_of_string(_n)
let rec a = (m, n) =>
switch (m, n) {
| (0, n) => (n+1)
| (m, 0) => a(m-1, 1)
| (m, n) => a(m-1, a(m, n-1))
}
Js.log("ackermann(" ++ _m ++ ", " ++ _n ++ ") = "
++ string_of_int(a(m, n)))

View file

@ -0,0 +1,7 @@
ackermann: func [m n] [
case [
m = 0 [n + 1]
n = 0 [ackermann m - 1 1]
true [ackermann m - 1 ackermann m n - 1]
]
]

View file

@ -0,0 +1,16 @@
ackermann: func [
m [integer!]
n [integer!]
] [
;; Small-m closed forms
case [
m = 0 [n + 1]
m = 1 [n + 2]
m = 2 [(2 * n) + 3]
m = 3 [
;; 2^(n+3) - 3
(to integer! power 2 (n + 3)) - 3
]
;; m >= 4 causes stack overflow
]
]

View file

@ -0,0 +1,18 @@
Fixpoint ack (m : nat) : nat -> nat :=
fix ack_m (n : nat) : nat :=
match m with
| 0 => S n
| S pm =>
match n with
| 0 => ack pm 1
| S pn => ack pm (ack_m pn)
end
end.
(*
Example:
A(3, 2) = 29
*)
Eval compute in ack 3 2.

View file

@ -0,0 +1,13 @@
Require Import Utf8.
Section FOLD.
Context {A : Type} (f : A → A) (a : A).
Fixpoint fold (n : nat) : A :=
match n with
| O => a
| S k => f (fold k)
end.
End FOLD.
Definition ackermann : nat → nat → nat :=
fold (λ g, fold g (g (S O))) S.

View file

@ -0,0 +1,7 @@
A ←|2.1 (
◡(×+1>0:>0)
sw(+1pop|A-1:1pop:
|A-1:off(A:-1:))
)
A 1 1

View file

@ -0,0 +1,20 @@
option explicit
'~ dim depth
function ack(m, n)
'~ wscript.stdout.write depth & " "
if m = 0 then
'~ depth = depth + 1
ack = n + 1
'~ depth = depth - 1
elseif m > 0 and n = 0 then
'~ depth = depth + 1
ack = ack(m - 1, 1)
'~ depth = depth - 1
'~ elseif m > 0 and n > 0 then
else
'~ depth = depth + 1
ack = ack(m - 1, ack(m, n - 1))
'~ depth = depth - 1
end if
end function

View file

@ -0,0 +1,5 @@
wscript.echo ack( 1, 10 )
'~ depth = 0
wscript.echo ack( 2, 1 )
'~ depth = 0
wscript.echo ack( 4, 4 )