Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Mutual-recursion/CLU/mutual-recursion.clu
Normal file
36
Task/Mutual-recursion/CLU/mutual-recursion.clu
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
% To declare things you can either write an .spc file or you can use
|
||||
% the clu file itself as a specfile. For a small program a common
|
||||
% idiom is to spec and compile the same source file:
|
||||
%
|
||||
% pclu -spec mutrec.clu -clu mutrec.clu
|
||||
%
|
||||
start_up = proc ()
|
||||
print_first_16("F", F)
|
||||
print_first_16("M", M)
|
||||
end start_up
|
||||
|
||||
% Print the first few values for F and M
|
||||
print_first_16 = proc (name: string, fn: proctype (int) returns (int))
|
||||
po: stream := stream$primary_output()
|
||||
stream$puts(po, name || ":")
|
||||
for i: int in int$from_to(0, 15) do
|
||||
stream$puts(po, " " || int$unparse(fn(i)))
|
||||
end
|
||||
stream$putl(po, "")
|
||||
end print_first_16
|
||||
|
||||
F = proc (n: int) returns (int)
|
||||
if n = 0 then
|
||||
return (1)
|
||||
else
|
||||
return (n - M(F(n-1)))
|
||||
end
|
||||
end F
|
||||
|
||||
M = proc (n: int) returns (int)
|
||||
if n = 0 then
|
||||
return (0)
|
||||
else
|
||||
return (n - F(M(n-1)))
|
||||
end
|
||||
end M
|
||||
Loading…
Add table
Add a link
Reference in a new issue