Mutual recursion: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
m minor simplification
added ol
Line 1,902: Line 1,902:
[0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12]
[0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 12]
</pre>
</pre>

=={{header|Ol}}==
The `letrec` indicates that the definitions can be recursive, and fact that we placed these two in the same letrec block makes them mutually recursive.
<lang scheme>
(letrec ((F (lambda (n)
(if (= n 0) 1
(- n (M (F (- n 1)))))))
(M (lambda (n)
(if (= n 0) 0
(- n (F (M (- n 1))))))))
(print (F 19)))
; produces 12
</lang>


=={{header|Order}}==
=={{header|Order}}==