Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Y operator

(idea) by neil (10.6 mon) (print)   ?   (I like it!) 1 C! Thu Jun 15 2000 at 14:50:33

In lambda calculus, the Y operator (also known as the Y combinator) computes the fixed point of a function. As a bit of background, note that everything in the lambda calculus is a function.

Given a function F, Y F is the function g such that g = F g. Autrement dit, Y F = F Y F.

A quick example (using pseudo-Lisp syntax as mjs did above):

nextfact = (lambda (f x) (if (<= x 1) 1 (* x (f (- x 1)))))
fact = (Y nextfact)
(fact 7) => 5040

Here's a definition of Y that works (in Scheme):

(define (Y f) ((lambda (x)
                  (lambda (z) (f (lambda (y)
                                    ((x x) y))
                               z)))
               (lambda (x)
                  (lambda (z) (f (lambda (y)
                                    ((x x) y))
                                 z)))))

In Common Lisp, it would be:

(defun Y (f) ((lambda (x)
                 (lambda (z) (funcall f (lambda (y)
                                           (funcall (funcall x x) y))
                                        z)))
              (lambda (x)
                 (lambda (z) (funcall f (lambda (y)
                                           (funcall (funcall x x) y))
                                        z)))))

This assumes you have a decent enough CL implementation to have the lambda macro. gcl, for one, doesn't have one, so you would need to insert #' in a few places above. In both of these, it only works with procedures of two arguments (including the f argument), and produces a procedure of one argument. In other languages, such as ML and Haskell, partial evaluation and currying allow any function to be written to take a single argument, so arity is not a problem.


printable version
chaos

fixed point combinator Lambda calculus Y combinator Autrement dit
combinator lambda currying functions Church numeral
fixed point curry Rocket Man trinary
recursion Sheepshank George Washington's 1795 State of the Union Address George Washington's 1790 State of the Union Address
IRC Ice cream cone John Adams's 1800 State of the Union Address Home designs and styles
iDEATH turing mutual recursion Ham
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Drink up!
Carole King
Five sonnets of vanity
A boy, a girl, a big fat dead old lady
trichotillomania
Dragon
Christianity
Innervisions
September 11, 2001
Under the Hood of the E2 Zen Theme
Wedge-tailed eagle
A Table Alphabeticall
Going to the movies in Thailand
Nystagmus
New Writeups
Nadine_2
The Sound Of Madness(review)
Twin Eclipse
Conversations with God: An Uncommon Dialogue(idea)
SwimmingMonkey
Conversations with Fo Fo- the Loneliest dog in Purgatory(fiction)
locke baron
lynx(thing)
Simulacron3
Reality, Dimensions and the Natural Ontology(essay)
SubSane
Making Love to a 9-Foot Woman(person)
Ouzo
Thoughts(idea)
antigravpussy
I fall silent, listening. The breadcrumbs are talking about us(person)
calgon
Buffalo Bill by the pool(poetry)
gate
Anarchy is Order(idea)
ushdfgakjasgh
Scribeling(thing)
XWiz
Trism(review)
artman2003
Briefcase Full of Souls - Part I(fiction)
Dreamvirus
Alan Ladd(person)
waverider37
Harold Holt(person)
Everything 2 is brought to you by the letter C and The Everything Development Company