Lambda?You Keep Using that Letter
@KevlinHenney
AWS
Half-Life
wavelength
decay constant
calculus
-calculus
We do not attach any
character of uniqueness
or absolute truth to any
particular system of logic.
The entities of formal logic are
abstractions, invented because of their
use in describing and systematizing
facts of experience or observation, and
their properties, determined in rough
outline by this intended use, depend
for their exact character on the
arbitrary choice of the inventor.
In 1911 Russell & Whitehead published Principia
Mathematica, with the goal of providing a solid
foundation for all of mathematics.
In 1911 Russell & Whitehead published Principia
Mathematica, with the goal of providing a solid
foundation for all of mathematics. In 1931 Gödel’s
Incompleteness Theorem shattered the dream,
showing that for any consistent axiomatic system
there will always be theorems that cannot be
proven within the system.
Adrian Colyer
https://blog.acolyer.org/2020/02/03/measure-mismeasure-fairness/
One premise of many models of fairness in
machine learning is that you can measure (‘prove’)
fairness of a machine learning model from within
the system – i.e. from properties of the model itself
and perhaps the data it is trained on.
To show that a machine learning model is fair, you
need information from outside of the system.
Adrian Colyer
https://blog.acolyer.org/2020/02/03/measure-mismeasure-fairness/
We demand rigidly
defined areas of doubt
and uncertainty!
Despite the fancy name, a
lambda is just a function...
peculiarly... without a name.
https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
There are only two hard things
in Computer Science: cache
invalidation and naming things.
Phil Karlton
There are only two hard things
in Computer Science: cache
invalidation and naming things.
Phil Karlton
We select a particular list of
symbols, consisting of the
symbols { , }, ( , ), λ, [ , ],
and an enumerably infinite
set of symbols a, b, c, · · · to
be called variables.
And we define the word
formula to mean any finite
sequence of symbols out of
this list.
f(x) = formula
f → λ x· formula
f → λ x· y x
variable
abstraction
application
f → λ x· y x
abbreviation free variable
bound variable
square(x) = x × x
square → λ x· x × x
square → λ 😠· 😠 × 😠
☐ → λ 😠· 😠 × 😠
☐ 7
square 7
(λ x· x × x) 7
AN UNSOLVEABLE
PROBLEM OF
ELEMENTARY
NUMBER THEORY
NUMBER
0
0 → λ f· λ x· x
1 → λ f· λ x· f(x)
2 → λ f· λ x· f(f(x))
3 → λ f· λ x· f(f(f(x)))
4 → λ f· λ x· f(f(f(f(x))))
5 → λ f· λ x· f(f(f(f(f(x)))))
0 → λ f x· x
1 → λ f x· f(x)
2 → λ f x· f(f(x))
3 → λ f x· f(f(f(x)))
4 → λ f x· f(f(f(f(x))))
5 → λ f x· f(f(f(f(f(x)))))
0 → λ f x· x
1 → λ f x· f x
2 → λ f x· f2 x
3 → λ f x· f3 x
4 → λ f x· f4 x
5 → λ f x· f5 x
6
0 → λ f x· f0 x
1 → λ f x· f1 x
2 → λ f x· f2 x
3 → λ f x· f3 x
4 → λ f x· f4 x
5 → λ f x· f5 x
6
7
7.times
7.times {|i| puts i}
0
1
2
3
4
5
0
1
2
3
4
5
0 → λ f x· x
1 → succ 0
2 → succ succ 0
3 → succ succ succ 0
4 → succ succ succ succ 0
5 → succ succ succ succ succ 0
0 → λ f x· x
1 → succ1 0
2 → succ2 0
3 → succ3 0
4 → succ4 0
5 → succ5 0
6
0 → λ f x· x
1 → succ 0
2 → succ 1
3 → succ 2
4 → succ 3
5 → succ 4
1 → succ → λ n f x· f (n f x)
You may have heard of lambdas
before. Perhaps you’ve used
them in other languages.
https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
auto square(auto x)
{
return x * x;
}
auto square = [](auto x)
{
return x * x;
};
square(7)
[](auto x)
{
return x * x;
}(7)
[](auto x) {return x * x;}(7)
They’re anonymous, little
functional spies sneaking
into the rest of your code.
https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
Excel is the world’s
most popular
functional language
Simon Peyton-Jones
(lambda (x) (* x x))
((lambda (x) (* x x)) 7)
http://xkcd.com/224/
http://xkcd.com/224/
http://xkcd.com/224/
http://xkcd.com/224/
We lost the documentation on quantum mechanics.
You'll have to decode the regexes yourself.
(int x) int: x * x
proc (int) int square;
square := (int x) int: x * x;
int result := square (7);
((int x) int: x * x) (7)
Lambdas in Ruby are
also objects, just like
everything else!
https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
The venerable master Qc Na was walking with his
student, Anton. Hoping to prompt the master into
a discussion, Anton said “Master, I have heard
that objects are a very good thing — is this true?”
Qc Na looked pityingly at his student and replied,
“Foolish pupil — objects are merely a poor man’s
closures.”
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
The concept of closures was developed in the
1960s for the mechanical evaluation of
expressions in the λ-calculus.
Peter J. Landin defined the term closure in
1964 as having an environment part and a
control part.
https://en.wikipedia.org/wiki/Closure_(computer_programming)
Joel Moses credits Landin with introducing
the term closure to refer to a lambda
expression whose open bindings (free
variables) have been closed by (or bound in)
the lexical environment, resulting in a closed
expression, or closure.
https://en.wikipedia.org/wiki/Closure_(computer_programming)
This usage was subsequently adopted by
Sussman and Steele when they defined
Scheme in 1975, a lexically scoped variant of
LISP, and became widespread.
https://en.wikipedia.org/wiki/Closure_(computer_programming)
Chastised, Anton took his leave from his master
and returned to his cell, intent on studying
closures. He carefully read the entire “Lambda:
The Ultimate...” series of papers and its cousins,
and implemented a small Scheme interpreter with a
closure-based object system.
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type -- EVAL" exp))))
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type -- EVAL" exp))))
This work developed out of an initial attempt
to understand the actorness of actors.
This interpreter attempted to intermix the
use of actors and LISP lambda expressions in
a clean manner.
“Scheme: An Interpreter for Extended Lambda Calculus”
Gerald Jay Sussman & Guy L Steele Jr
When it was completed, we discovered that
the “actors” and the lambda expressions
were identical in implementation.
“Scheme: An Interpreter for Extended Lambda Calculus”
Gerald Jay Sussman & Guy L Steele Jr
On his next walk with Qc Na, Anton attempted
to impress his master by saying “Master, I have
diligently studied the matter, and now understand
that objects are truly a poor man’s closures.”
Qc Na responded by hitting Anton with his stick,
saying “When will you learn? Closures are a poor
man’s object.”
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
At that moment, Anton became enlightened.
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
λ-calculus was the
first object-oriented
language.
One of the most powerful
mechanisms for program
structuring [...] is the block
and procedure concept.
Ole-Johan Dahl and C A R Hoare
“Hierarchical Program Structures”
begin
ref(Rock) array items(1:capacity);
integer count;
integer procedure Depth; ...
ref(Rock) procedure Top; ...
procedure Push(top); ...
procedure Pop; ...
count := 0
end;
A procedure which is capable of
giving rise to block instances which
survive its call will be known as a
class; and the instances will be
known as objects of that class.
Ole-Johan Dahl and C A R Hoare
“Hierarchical Program Structures”
class Stack(capacity);
integer capacity;
begin
ref(Rock) array items(1:capacity);
integer count;
integer procedure Depth; ...
ref(Rock) procedure Top; ...
procedure Push(top); ...
procedure Pop; ...
count := 0
end;
We could, of course, use any notation
we want; do not laugh at notations;
invent them, they are powerful.
In fact, mathematics is, to a large
extent, invention of better notations.
Richard Feynman
lambda
function
fn
=>
->
[]
[](){}
[](){}()
[[]]([]()[[]]{}={})()
https://twitter.com/shafikyaghmour/status/1128790426519871496
f → λ x· y x
variable
abstraction
application
[](auto x) {return x * x;}(7)
abstraction variable application
“Oh God,” muttered Ford, slumped against
a bulkhead and started to count to ten.
He was desperately worried that one day
sentient life forms would forget how to do this.
Only by counting could humans demonstrate
their independence of computers.
0 → λ f· λ x· x
1 → λ f· λ x· f(x)
2 → λ f· λ x· f(f(x))
3 → λ f· λ x· f(f(f(x)))
4 → λ f· λ x· f(f(f(f(x))))
5 → λ f· λ x· f(f(f(f(f(x)))))
_0 = f => x => x
_1 = f => x => f(x)
_2 = f => x => f(f(x))
_3 = f => x => f(f(f(x)))
_4 = f => x => f(f(f(f(x))))
_5 = f => x => f(f(f(f(f(x)))
_0 = f => x => x
_1 = succ(_0)
_2 = succ(_1)
_3 = succ(_2)
_4 = succ(_3)
_5 = succ(_4)
succ = n => f => x => f(n(f)(x))
auto succ =
[](auto n)
{
return [=](auto f)
{
return [=](auto x)
{
return f(n(f)(x));
};
};
};
auto _0 =
[](auto f)
{
return [=](auto x)
{
return x;
};
};
auto _0 = ...;
auto _1 = succ(_0);
auto _2 = succ(_1);
auto _3 = succ(_2);
auto _4 = succ(_3);
auto _5 = succ(_4);
auto plus_1 = [](auto n)
{
return n + 1;
};
_0
_0(plus_1)
_0(plus_1)(0)
_1(plus_1)(0)
_2(plus_1)(0)
_3(plus_1)(0)
_4(plus_1)(0)
_5(plus_1)(0)
0
1
2
3
4
5
auto plus_1 = [](auto n)
{
return n + lexical_cast<decltype(n)>(1);
};
_0(plus_1)(0)
_1(plus_1)(0)
_2(plus_1)(0)
_3(plus_1)(0)
_4(plus_1)(0)
_5(plus_1)(0)
0
1
2
3
4
5
_0(plus_1)(“”s)
_1(plus_1)(“”s)
_2(plus_1)(“”s)
_3(plus_1)(“”s)
_4(plus_1)(“”s)
_5(plus_1)(“”s)
1
11
111
1111
11111
square
auto square = [](auto m)
{
return _2(m);
};
square(_7)
square(_7)(plus_1)
square(_7)(plus_1)(0)
49
true
false
true → λ a b· a
false → λ a b· b
7 * 7 < limit
ifTrue: [^ ‘👍’]
ifFalse: [^ ‘👎’]
True
ifTrue: toDo ifFalse: ignore
^ toDo value
False
ifTrue: ignore ifFalse: toDo
^ toDo value
false → λ a b· b
false → λ 🙂☹· ☹
false → λ f x· x
false = 0
pair → λ x y f· f(x)(y)
first → λ p· p(λ x y· x)
second → λ p· p(λ x y· y)
pair → λ x y f· f x y
first → λ p· p true
second → λ p· p false
cons → λ x y f· f x y
car → λ p· p true
cdr → λ p· p false
nil → false
cons → λ x y f· f x y
car → λ p· p true
cdr → λ p· p false
nil → false
push → λ x y f· f x y
top → λ p· p true
pop → λ p· p false
stack → false
People who brook no compromise
in programming languages should
program in lambda calculus or
machine language.
Andrew Koenig
Lambda? You Keep Using that Letter

Lambda? You Keep Using that Letter

  • 1.
    Lambda?You Keep Usingthat Letter @KevlinHenney
  • 3.
  • 4.
  • 6.
    We do notattach any character of uniqueness or absolute truth to any particular system of logic.
  • 7.
    The entities offormal logic are abstractions, invented because of their use in describing and systematizing facts of experience or observation, and their properties, determined in rough outline by this intended use, depend for their exact character on the arbitrary choice of the inventor.
  • 9.
    In 1911 Russell& Whitehead published Principia Mathematica, with the goal of providing a solid foundation for all of mathematics. In 1911 Russell & Whitehead published Principia Mathematica, with the goal of providing a solid foundation for all of mathematics. In 1931 Gödel’s Incompleteness Theorem shattered the dream, showing that for any consistent axiomatic system there will always be theorems that cannot be proven within the system. Adrian Colyer https://blog.acolyer.org/2020/02/03/measure-mismeasure-fairness/
  • 10.
    One premise ofmany models of fairness in machine learning is that you can measure (‘prove’) fairness of a machine learning model from within the system – i.e. from properties of the model itself and perhaps the data it is trained on. To show that a machine learning model is fair, you need information from outside of the system. Adrian Colyer https://blog.acolyer.org/2020/02/03/measure-mismeasure-fairness/
  • 12.
    We demand rigidly definedareas of doubt and uncertainty!
  • 14.
    Despite the fancyname, a lambda is just a function... peculiarly... without a name. https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
  • 15.
    There are onlytwo hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  • 16.
    There are onlytwo hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  • 18.
    We select aparticular list of symbols, consisting of the symbols { , }, ( , ), λ, [ , ], and an enumerably infinite set of symbols a, b, c, · · · to be called variables.
  • 19.
    And we definethe word formula to mean any finite sequence of symbols out of this list.
  • 20.
  • 21.
    f → λx· formula
  • 22.
    f → λx· y x variable abstraction application
  • 23.
    f → λx· y x abbreviation free variable bound variable
  • 24.
  • 25.
    square → λx· x × x
  • 26.
    square → λ😠· 😠 × 😠
  • 27.
    ☐ → λ😠· 😠 × 😠
  • 28.
  • 29.
  • 30.
    (λ x· x× x) 7
  • 32.
  • 33.
  • 35.
  • 36.
    0 → λf· λ x· x 1 → λ f· λ x· f(x) 2 → λ f· λ x· f(f(x)) 3 → λ f· λ x· f(f(f(x))) 4 → λ f· λ x· f(f(f(f(x)))) 5 → λ f· λ x· f(f(f(f(f(x)))))
  • 37.
    0 → λf x· x 1 → λ f x· f(x) 2 → λ f x· f(f(x)) 3 → λ f x· f(f(f(x))) 4 → λ f x· f(f(f(f(x)))) 5 → λ f x· f(f(f(f(f(x)))))
  • 38.
    0 → λf x· x 1 → λ f x· f x 2 → λ f x· f2 x 3 → λ f x· f3 x 4 → λ f x· f4 x 5 → λ f x· f5 x 6
  • 39.
    0 → λf x· f0 x 1 → λ f x· f1 x 2 → λ f x· f2 x 3 → λ f x· f3 x 4 → λ f x· f4 x 5 → λ f x· f5 x 6
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
    0 1 2 3 4 5 0 → λf x· x 1 → succ 0 2 → succ succ 0 3 → succ succ succ 0 4 → succ succ succ succ 0 5 → succ succ succ succ succ 0
  • 45.
    0 → λf x· x 1 → succ1 0 2 → succ2 0 3 → succ3 0 4 → succ4 0 5 → succ5 0 6
  • 46.
    0 → λf x· x 1 → succ 0 2 → succ 1 3 → succ 2 4 → succ 3 5 → succ 4
  • 47.
    1 → succ→ λ n f x· f (n f x)
  • 48.
    You may haveheard of lambdas before. Perhaps you’ve used them in other languages. https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
  • 49.
  • 50.
    auto square =[](auto x) { return x * x; };
  • 51.
  • 52.
  • 53.
  • 54.
    They’re anonymous, little functionalspies sneaking into the rest of your code. https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
  • 55.
    Excel is theworld’s most popular functional language Simon Peyton-Jones
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
    http://xkcd.com/224/ We lost thedocumentation on quantum mechanics. You'll have to decode the regexes yourself.
  • 64.
  • 65.
    proc (int) intsquare; square := (int x) int: x * x; int result := square (7);
  • 66.
    ((int x) int:x * x) (7)
  • 67.
    Lambdas in Rubyare also objects, just like everything else! https://rubymonk.com/learning/books/1-ruby-primer/chapters/34-lambdas-and-blocks-in-ruby/lessons/77-lambdas-in-ruby
  • 68.
    The venerable masterQc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said “Master, I have heard that objects are a very good thing — is this true?” Qc Na looked pityingly at his student and replied, “Foolish pupil — objects are merely a poor man’s closures.” http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
  • 69.
    The concept ofclosures was developed in the 1960s for the mechanical evaluation of expressions in the λ-calculus. Peter J. Landin defined the term closure in 1964 as having an environment part and a control part. https://en.wikipedia.org/wiki/Closure_(computer_programming)
  • 70.
    Joel Moses creditsLandin with introducing the term closure to refer to a lambda expression whose open bindings (free variables) have been closed by (or bound in) the lexical environment, resulting in a closed expression, or closure. https://en.wikipedia.org/wiki/Closure_(computer_programming)
  • 71.
    This usage wassubsequently adopted by Sussman and Steele when they defined Scheme in 1975, a lexically scoped variant of LISP, and became widespread. https://en.wikipedia.org/wiki/Closure_(computer_programming)
  • 72.
    Chastised, Anton tookhis leave from his master and returned to his cell, intent on studying closures. He carefully read the entire “Lambda: The Ultimate...” series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
  • 74.
    (define (eval expenv) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp) env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "Unknown expression type -- EVAL" exp))))
  • 75.
    (define (eval expenv) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp) env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "Unknown expression type -- EVAL" exp))))
  • 76.
    This work developedout of an initial attempt to understand the actorness of actors. This interpreter attempted to intermix the use of actors and LISP lambda expressions in a clean manner. “Scheme: An Interpreter for Extended Lambda Calculus” Gerald Jay Sussman & Guy L Steele Jr
  • 77.
    When it wascompleted, we discovered that the “actors” and the lambda expressions were identical in implementation. “Scheme: An Interpreter for Extended Lambda Calculus” Gerald Jay Sussman & Guy L Steele Jr
  • 78.
    On his nextwalk with Qc Na, Anton attempted to impress his master by saying “Master, I have diligently studied the matter, and now understand that objects are truly a poor man’s closures.” Qc Na responded by hitting Anton with his stick, saying “When will you learn? Closures are a poor man’s object.” http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
  • 79.
    At that moment,Anton became enlightened. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
  • 81.
    λ-calculus was the firstobject-oriented language.
  • 92.
    One of themost powerful mechanisms for program structuring [...] is the block and procedure concept. Ole-Johan Dahl and C A R Hoare “Hierarchical Program Structures”
  • 93.
    begin ref(Rock) array items(1:capacity); integercount; integer procedure Depth; ... ref(Rock) procedure Top; ... procedure Push(top); ... procedure Pop; ... count := 0 end;
  • 94.
    A procedure whichis capable of giving rise to block instances which survive its call will be known as a class; and the instances will be known as objects of that class. Ole-Johan Dahl and C A R Hoare “Hierarchical Program Structures”
  • 95.
    class Stack(capacity); integer capacity; begin ref(Rock)array items(1:capacity); integer count; integer procedure Depth; ... ref(Rock) procedure Top; ... procedure Push(top); ... procedure Pop; ... count := 0 end;
  • 96.
    We could, ofcourse, use any notation we want; do not laugh at notations; invent them, they are powerful. In fact, mathematics is, to a large extent, invention of better notations. Richard Feynman
  • 103.
  • 104.
  • 105.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 113.
  • 114.
    f → λx· y x variable abstraction application
  • 115.
    [](auto x) {returnx * x;}(7) abstraction variable application
  • 117.
    “Oh God,” mutteredFord, slumped against a bulkhead and started to count to ten. He was desperately worried that one day sentient life forms would forget how to do this. Only by counting could humans demonstrate their independence of computers.
  • 118.
    0 → λf· λ x· x 1 → λ f· λ x· f(x) 2 → λ f· λ x· f(f(x)) 3 → λ f· λ x· f(f(f(x))) 4 → λ f· λ x· f(f(f(f(x)))) 5 → λ f· λ x· f(f(f(f(f(x)))))
  • 119.
    _0 = f=> x => x _1 = f => x => f(x) _2 = f => x => f(f(x)) _3 = f => x => f(f(f(x))) _4 = f => x => f(f(f(f(x)))) _5 = f => x => f(f(f(f(f(x)))
  • 120.
    _0 = f=> x => x _1 = succ(_0) _2 = succ(_1) _3 = succ(_2) _4 = succ(_3) _5 = succ(_4)
  • 121.
    succ = n=> f => x => f(n(f)(x))
  • 122.
    auto succ = [](auton) { return [=](auto f) { return [=](auto x) { return f(n(f)(x)); }; }; };
  • 123.
    auto _0 = [](autof) { return [=](auto x) { return x; }; };
  • 124.
    auto _0 =...; auto _1 = succ(_0); auto _2 = succ(_1); auto _3 = succ(_2); auto _4 = succ(_3); auto _5 = succ(_4);
  • 125.
    auto plus_1 =[](auto n) { return n + 1; };
  • 126.
  • 127.
  • 128.
  • 129.
    auto plus_1 =[](auto n) { return n + lexical_cast<decltype(n)>(1); };
  • 130.
  • 131.
  • 132.
  • 133.
    auto square =[](auto m) { return _2(m); };
  • 134.
  • 135.
  • 136.
  • 137.
  • 139.
  • 140.
    true → λa b· a false → λ a b· b
  • 142.
    7 * 7< limit ifTrue: [^ ‘👍’] ifFalse: [^ ‘👎’]
  • 143.
    True ifTrue: toDo ifFalse:ignore ^ toDo value
  • 144.
  • 145.
    false → λa b· b
  • 146.
    false → λ🙂☹· ☹
  • 147.
    false → λf x· x
  • 148.
  • 150.
    pair → λx y f· f(x)(y) first → λ p· p(λ x y· x) second → λ p· p(λ x y· y)
  • 151.
    pair → λx y f· f x y first → λ p· p true second → λ p· p false
  • 152.
    cons → λx y f· f x y car → λ p· p true cdr → λ p· p false nil → false
  • 154.
    cons → λx y f· f x y car → λ p· p true cdr → λ p· p false nil → false
  • 155.
    push → λx y f· f x y top → λ p· p true pop → λ p· p false stack → false
  • 158.
    People who brookno compromise in programming languages should program in lambda calculus or machine language. Andrew Koenig