Content deleted Content added
→Prevalence: Added Blockquote Tags: Mobile edit Mobile web edit Advanced mobile edit |
m Mutual recursion can occur between two *or more* mathematical/computational objects, not just two. This introductory wording in the definition is more consistent with the rest of the article. Tags: Visual edit Mobile edit Mobile web edit |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1:
{{short description|
<!-- [[WP:NFCC]] violation: [[File:DrawingHands.jpg|thumb|upright|"[[Drawing Hands]]", a drawing by [[M. C. Escher]]]] -->
In [[mathematics]] and [[computer science]], '''mutual recursion''' is a form of [[Recursion (computer science)|recursion]] where two or more mathematical or computational objects, such as functions or datatypes, are defined in terms of each other.<ref>Manuel Rubio-Sánchez, Jaime Urquiza-Fuentes, Cristóbal Pareja-Flores (2002), 'A Gentle Introduction to Mutual Recursion', Proceedings of the 13th annual conference on Innovation and technology in computer science education, June 30–July 2, 2008, Madrid, Spain.</ref> Mutual recursion is very common in [[functional programming]] and in some problem domains, such as [[recursive descent parser]]s, where the datatypes are naturally mutually recursive.
==Examples==
Line 66:
</syntaxhighlight>
A more detailed example in [[Scheme (programming language)|Scheme]], counting the leaves of a tree:{{sfn|Harvey|Wright|1999|loc=V. Abstraction: 18. Trees: Mutual Recursion, pp. [https://books.google.com/books?id=igJRhp0KGn8C&pg=PA310&dq=%22mutual%20recursion%22 310–313]}}
<syntaxhighlight lang=scheme>
(define (count-leaves tree)
|