Mutual recursion: Difference between revisions

Add Draco
(Add CLU)
(Add Draco)
Line 1,191:
6 6
6 6 </pre>
 
=={{header|Draco}}==
<lang draco>/* 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</lang>
{{out}}
<pre>F: 1 1 2 2 3 3 4 5 5 6 6 7 8 8 9 9
M: 0 0 1 2 2 3 4 4 5 6 6 7 7 8 9 9</pre>
 
=={{header|Dyalect}}==
2,115

edits