RosettaCodeData/Task/Sudan-function/Draco/sudan-function.draco

39 lines
744 B
Plaintext

proc sudan(word n, x, y) word:
word k;
if n=0 then
x + y
elif y=0 then
x
else
k := sudan(n, x, y-1);
sudan(n-1, k, k+y)
fi
corp
proc table(word n, xs, ys) void:
word x, y;
writeln("sudan(",n,",x,y):");
write(" ");
for x from 0 upto xs do write(x:5) od;
for y from 0 upto ys do
writeln();
write(y:4, ":");
for x from 0 upto xs do write(sudan(n,x,y):5) od;
od;
writeln();
writeln()
corp
proc show(word n, x, y) void:
writeln("sudan(", n:1, ",", x:3, ",", y:3, ") = ", sudan(n,x,y):5)
corp
proc main() void:
table(0, 6, 5);
table(1, 6, 5);
show(1, 3, 3);
show(2, 1, 1);
show(2, 2, 1);
show(3, 1, 1)
corp