Mutual recursion: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|REBOL}}: Remove vanity tags) |
m (minor simplification) |
||
Line 2,014: | Line 2,014: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
You should normally explicitly declare forward routines (strictly necessary only when using optional or named parameters), since it often makes things easier to understand. There would be no point pre-declaring F, since it is not called before it is defined anyway. |
|||
<lang Phix>function |
<lang Phix>forward function M(integer n) |
||
⚫ | |||
return iff(n?n-M(F(n-1)):1) |
return iff(n?n-M(F(n-1)):1) |
||
end function |
end function |
||
Line 2,029: | Line 2,032: | ||
printf(1," %d",M(i)) |
printf(1," %d",M(i)) |
||
end for</lang> |
end for</lang> |
||
You can also explicitly declare forward routines, which may sometimes be necessary for routines with optional or named parameters, or just make something easier to understand. |
|||
<lang Phix>forward function F(integer n) |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |