Mutual recursion: Difference between revisions

m
→‎{{header|CLU}}: Oops, untabify previous
(→‎{{header|CLU}}: Correct and clarify the Clu example. No special tricks are needed for mutual recursion, it's standard practice to "spec" the clu file before compiling it.)
m (→‎{{header|CLU}}: Oops, untabify previous)
Line 1,049:
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">% To declare things you can either write an .spc file or you can use
% 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:
Line 1,065 ⟶ 1,066:
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, "")
Line 1,072 ⟶ 1,073:
F = proc (n: int) returns (int)
if n = 0 then
return (1)
else
return (n - M(F(n-1)))
end
end F
Line 1,080 ⟶ 1,081:
M = proc (n: int) returns (int)
if n = 0 then
return (0)
else
return (n - F(M(n-1)))
end
end M
3

edits