Mutual recursion

This is an old revision of this page, as edited by Oleg Alexandrov (talk | contribs) at 01:09, 2 June 2005 (I think this is much more a {{compu-lang-stub}} than a {{math-stub}}). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Mutual recursion is a form of recursion where two mathematical or computational functions are defined in terms of each other.

For instance, consider two functions A(x) and B(x) defined as follows:


Mutual recursion is very common in the functional programming style, and is often used for programs written in LISP, Scheme, ML, and similar languages. In languages such as Prolog, mutual recursion is almost unavoidable.

Some programming styles discourage mutual recursion, claiming that it can be confusing to distinguish the conditions which will return an answer from the conditions that would allow the code to run forever without producing an answer.