37 lines
917 B
Plaintext
37 lines
917 B
Plaintext
% 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
|