Mutual recursion: Difference between revisions

Content deleted Content added
m linking
eval-apply cycle
Line 96:
 
==Prevalence==
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]]. For example, Abelson and Sussman describe how a [[Meta-circular evaluator|metacircular evaluator]] can be used to implement LISP with an eval-apply cycle.<ref>{{Cite book|last=Abelson|first=Harold|url=https://web.mit.edu/alexmv/6.037/sicp.pdf|title=Structure and Interpretationof Computer Programs|last2=Sussman|first2=Gerald Jay|last3=Sussman|first3=Julie|publisher=The MIT Press|year=1996|isbn=978-0262510875|___location=London, England|pages=492}}</ref> 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. [[Peter Norvig]] points to a [[design pattern]] which discourages the use entirely, stating:<ref>[http://norvig.com/sudoku.html Solving Every Sudoku Puzzle]</ref>