def add_ten(a):
return a + 10
def multiply(a, b):
return a * b
def sum_three(a, b, c):
return a + b + c
x1 = lambda a : a + 10
print(x1(5))
x2 = lambda a, b : a * b
print(x2(5, 6))
x3 = lambda a, b, c : a + b + c
print(x3(5, 6, 2))
In pure $\lambda$-calculus, functions technically only take one input at a time. Python allows lambda a, b as a shortcut, but behind the scenes, it follows these rules:
| Python Shorthand | Pure $\lambda$ Logic | What happens? (Application) |
|---|---|---|
lambda a: a + 10 |
$\lambda a . (a + 10)$ | Input 5 replaces a in the body. |
lambda a, b: a * b |
$\lambda a . \lambda b . (a * b)$ | Input 5 fills a, then input 6 fills b. |
lambda a, b, c: ... |
$\lambda a . \lambda b . \lambda c . (\text{body})$ | A chain of 3 applications occurs. |
The Body (M): In your examples, the "Body" of the λ-term is the math operation (like a + b + c).
The Variable (V): The letters a, b, and c are the variables.
The Application (MM): When you write x(5, 6, 2), you are applying the function x to the values.