Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Fixed-point combinator
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
===Example implementations=== An example implementation of ''Y'' in the language [[R (programming language)|R]] is presented below:<syntaxhighlight lang="r"> Y <- \(f) { g <- \(x) f(x(x)) g(g) } </syntaxhighlight>This can then be used to implement factorial as follows:<syntaxhighlight lang="r"> fact <- \(f) \(n) if (n == 0) 1 else n * f(n - 1) Y(fact)(5) # yields 5! = 120 </syntaxhighlight>Y is only needed when function names are absent. Substituting all the definitions into one line so that function names are not required gives:<syntaxhighlight lang="r"> (\(f) (\(x) f(x(x)))(\(x) f(x(x)))) (\(f) \(n) if (n == 0) 1 else n * f(n - 1)) (5) </syntaxhighlight>This works because R uses [[lazy evaluation]]. Languages that use [[strict evaluation]], such as [[Python (programming language)|Python]], [[C++]], and other [[strict programming language]]s, can often express Y; however, any implementation is useless in practice since it [[infinite loop|loops indefinitely]] until terminating via a [[stack overflow]].
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Fixed-point combinator
(section)
Add topic