Related pages:
The program omega is made up of two functions which each take one argument. Each of these functions applies the argument to itself. Omega is then the application of one of these functions to the other:
var omega = (function (f){f(f);})(function (g){g(g);}) ;
Trying to evaluate this code fragment will hang the browser until it decides to terminate the script.
The means by which omega achieves non-termination is self-application, and self-application turns out to be the theoretical source of power for the computational universality of the lambda-calculus.
(Self-application creates a number of issues needing careful handling for logical theories based on the lambda-calculus, but these aren’t a concern when the lambda-calculus is used as the basis of a programming language.)
More specifically, self-application allows the construction of fixed combinators, such as the Y combinator, and these permit the construction of recursive functions without explicit support for recursion.
I’ve also created an article demonstrating the Y combinator and showing how it can be used for memoizing recursive functions.
Twitter: @mattmight
Instagram: @mattmight
LinkedIn: matthewmight
Mastodon: @mattmight@mathstodon.xyz
Sub-reddit: /r/mattmight