Combinators are small, reusable function patterns. They don’t rely on variables or external state — they only use the inputs you give them. Think of them as the “grammar rules” of functions.
Below, each combinator is explained with intuition, diagrams, and Python equivalents.
| Lambda Calculus | Python Equivalent |
|---|---|
|
λx.x
“Take x and return x unchanged. A pure pass‑through function.”
|
I = lambda x: x |
| Lambda Calculus | Python Equivalent |
|---|---|
|
λxy.x
“Take x, then take y, but always return x. The second input is ignored entirely.”
|
K = lambda x: (lambda y: x) |
| Lambda Calculus | Python Equivalent |
|---|---|
|
λxyz. x(z)(y(z))
“λxyz is shorthand for λx.λy.λz — a function that takes x, then returns a function waiting for y, then returns a function waiting for z.
After receiving all three, it runs both x and y on z.
Then it treats x(z) as a function and feeds it the result of y(z).
This lets two computations share the same input and then combine their outputs.”
|
S = lambda x: (lambda y: (lambda z: x(z)(y(z)))) |
| Lambda Calculus | Python Equivalent |
|---|---|
|
λx.xx
“λx means the function takes one argument called x.
The body xx means ‘apply x to itself’, written as x(x).
This pattern allows a function to receive its own definition as input, forming the basis of recursive behaviour.”
|
B = lambda x: x(x) |