Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Mutual recursion
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Prevalence== Mutual recursion is very common in [[functional programming]], and is often used for programs written in [[Lisp (programming language)|LISP]], [[Scheme (programming language)|Scheme]], [[ML (programming language)|ML]], and similar [[programming language]]s. For example, Abelson and Sussman describe how a [[meta-circular 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 Interpretation of 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]], 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> {{Blockquote|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.}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)