Content deleted Content added
merged two statements |
|||
Line 19:
Mutual recursion is very common in the [[functional programming]] style, and is often used for programs written in [[Lisp programming language|LISP]], [[Scheme (programming language)|Scheme]], [[ML programming language|ML]], and similar [[programming language|languages]]. In languages such as [[Prolog programming language|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
{{quote|text=If you have two mutually-recursive functions that both alter the state of an object, try to move almost all the functionality into just one of the functions. Otherwise you will probably end up duplicating code.|sign=Peter Norvig <ref>[http://norvig.com/sudoku.html Solving Every Sudoku Puzzle]</ref>}}
Any mutual recursion can be converted to direct recursion
In mathematics, the [[Hofstadter sequence#Hofstadter Female and Male sequences|Hofstadter Female and Male sequences]] are an example of a pair of integer sequences defined in a mutually recursive manner.
|