Mutual recursion: Difference between revisions
Content added Content deleted
(Updated D entry) |
(→{{header|Perl}}: remove unnecessary prelude; improve clarity) |
||
Line 1,417: | Line 1,417: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
<lang perl> |
<lang perl>sub F { my $n = shift; $n ? $n - M(F($n-1)) : 1 } |
||
⚫ | |||
use warnings; |
|||
# Usage: |
|||
# For mutually recursive functions, |
|||
⚫ | |||
# predeclaring is probably a good idea. |
|||
⚫ | |||
sub M; sub F; |
|||
sub F { my $n = shift; $n ? $n - M F $n-1 : 1 } |
|||
⚫ | |||
⚫ | |||
⚫ | |||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |