Y-combinator
eharetea

Y-combinator is a way of defining a function that can call itself without the define function.

Y-combinator is a way of defining a function that can call itself without the define function.

Date Created:Tuesday September 30th, 2008 10:43 AM
Date Modified:Tuesday January 19th, 2010 10:35 PM

First, create the function for passing in the parameters:

```(lambda (x)
```
Now, create the function that will pass the function that it receives as input into that function that it receives. Let function a be the function we are creating. Function b is an argument to a. Function a will call b with b as an argument to b, along with its argument. This is what we call the "Y-combinator":
```(lambda (f n) (f f n))
```
Now create the function that actually does what we want. the procedure we may want to call it.
```(lambda (factorial n)
(if (= n 0)
1
(* n (factorial factorial (- n 1)))))
```
Now pass in the initial argument
```x))
```

```(lambda (x)
(lambda (f n) (f f n))
(lambda (factorial n)
(if (= n 0)
1
(* n factorial factorial (- n 1)))))
x))
```