Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Ackermann-function/Sather/ackermann-function-1.sa
Normal file
19
Task/Ackermann-function/Sather/ackermann-function-1.sa
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class MAIN is
|
||||
|
||||
ackermann(m, n:INT):INT
|
||||
pre m >= 0 and n >= 0
|
||||
is
|
||||
if m = 0 then return n + 1; end;
|
||||
if n = 0 then return ackermann(m-1, 1); end;
|
||||
return ackermann(m-1, ackermann(m, n-1));
|
||||
end;
|
||||
|
||||
main is
|
||||
n, m :INT;
|
||||
loop n := 0.upto!(6);
|
||||
loop m := 0.upto!(3);
|
||||
#OUT + "A(" + m + ", " + n + ") = " + ackermann(m, n) + "\n";
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
19
Task/Ackermann-function/Sather/ackermann-function-2.sa
Normal file
19
Task/Ackermann-function/Sather/ackermann-function-2.sa
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class MAIN is
|
||||
|
||||
ackermann(m, n:INTI):INTI is
|
||||
zero ::= 0.inti; -- to avoid type conversion each time
|
||||
one ::= 1.inti;
|
||||
if m = zero then return n + one; end;
|
||||
if n = zero then return ackermann(m-one, one); end;
|
||||
return ackermann(m-one, ackermann(m, n-one));
|
||||
end;
|
||||
|
||||
main is
|
||||
n, m :INT;
|
||||
loop n := 0.upto!(6);
|
||||
loop m := 0.upto!(3);
|
||||
#OUT + "A(" + m + ", " + n + ") = " + ackermann(m.inti, n.inti) + "\n";
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue