Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Mutual-recursion/Draco/mutual-recursion.draco
Normal file
26
Task/Mutual-recursion/Draco/mutual-recursion.draco
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* We need to predeclare M if we want F to be able to see it.
|
||||
* This is done using 'extern', same as if it had been in a
|
||||
* different compilation unit. */
|
||||
extern M(byte n) byte;
|
||||
|
||||
/* Mutually recursive functions */
|
||||
proc F(byte n) byte:
|
||||
if n=0 then 1 else n - M(F(n-1)) fi
|
||||
corp
|
||||
|
||||
proc M(byte n) byte:
|
||||
if n=0 then 0 else n - F(M(n-1)) fi
|
||||
corp
|
||||
|
||||
/* Show the first 16 values of each */
|
||||
proc nonrec main() void:
|
||||
byte i;
|
||||
|
||||
write("F:");
|
||||
for i from 0 upto 15 do write(F(i):2) od;
|
||||
writeln();
|
||||
|
||||
write("M:");
|
||||
for i from 0 upto 15 do write(M(i):2) od;
|
||||
writeln()
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue