Jump to content

Mutual recursion

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sethg (talk | contribs) at 16:28, 26 September 2001. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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:


 A(x, x<=1) = 1
 A(x where x>1) = B(x + 2)
 B(x) = A(x - 3) + 4


It is not obvious from inspection under what circumstances calling either of these functions will ever reach the non-recursive case

and thus return an answer, and this often holds true even for non-contrived examples. Therefore, is computer programming,

mutually recursive functions are generally regarded as bad style.