SlideShare a Scribd company logo
1 of 159
Download to read offline
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

More Related Content

What's hot

Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Bryan O'Sullivan
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Bryan O'Sullivan
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...Philip Schwarz
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Bryan O'Sullivan
 
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions Ganesh Samarthyam
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Vadim Dubs
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Bryan O'Sullivan
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummiesknutmork
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldPhilip Schwarz
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data scienceJohn Cant
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocamlpramode_ce
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziński
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...Philip Schwarz
 
Java Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsJava Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsRakesh Waghela
 
Scala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypeScala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypePhilip Schwarz
 

What's hot (20)

Real World Haskell: Lecture 5
Real World Haskell: Lecture 5Real World Haskell: Lecture 5
Real World Haskell: Lecture 5
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit - Haskell and...
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
 
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
OCP Java SE 8 Exam - Sample Questions - Lambda Expressions
 
Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.Javaz. Functional design in Java 8.
Javaz. Functional design in Java 8.
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummies
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and Fold
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
 
Java generics
Java genericsJava generics
Java generics
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
N-Queens Combinatorial Problem - Polyglot FP for Fun and Profit – Haskell and...
 
Haskell
HaskellHaskell
Haskell
 
Java Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsJava Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and Pitfalls
 
Scala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data TypeScala 3 enum for a terser Option Monad Algebraic Data Type
Scala 3 enum for a terser Option Monad Algebraic Data Type
 

Similar to Lambda? You Keep Using that Letter

Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey Hakka Labs
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languagessuthi
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scalaehsoon
 
Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismEelco Visser
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyTypesafe
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data ManagementAlbert Bifet
 
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012taxonbytes
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory buildingClarkTony
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already KnowKevlin Henney
 
Functional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersFunctional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersChris
 
Metaprogramming in Scala 2.10, Eugene Burmako,
Metaprogramming  in Scala 2.10, Eugene Burmako, Metaprogramming  in Scala 2.10, Eugene Burmako,
Metaprogramming in Scala 2.10, Eugene Burmako, Vasil Remeniuk
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospectivechenge2k
 
Programming with Millions of Examples (HRL)
Programming with Millions of Examples (HRL)Programming with Millions of Examples (HRL)
Programming with Millions of Examples (HRL)Eran Yahav
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskellgoncharenko
 

Similar to Lambda? You Keep Using that Letter (20)

Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languages
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scala
 
Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: Polymorphism
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
 
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012
Franz et. al. 2012. Reconciling Succeeding Classifications, ESA 2012
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
Functional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative ProgrammersFunctional Programming Concepts for Imperative Programmers
Functional Programming Concepts for Imperative Programmers
 
Introducing scala
Introducing scalaIntroducing scala
Introducing scala
 
Scala Bootcamp 1
Scala Bootcamp 1Scala Bootcamp 1
Scala Bootcamp 1
 
Metaprogramming in Scala 2.10, Eugene Burmako,
Metaprogramming  in Scala 2.10, Eugene Burmako, Metaprogramming  in Scala 2.10, Eugene Burmako,
Metaprogramming in Scala 2.10, Eugene Burmako,
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
Haskell retrospective
Haskell retrospectiveHaskell retrospective
Haskell retrospective
 
Programming with Millions of Examples (HRL)
Programming with Millions of Examples (HRL)Programming with Millions of Examples (HRL)
Programming with Millions of Examples (HRL)
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
 

More from Kevlin Henney

The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical ExcellenceKevlin Henney
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical DevelopmentKevlin Henney
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid DeconstructionKevlin Henney
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test CasesKevlin Henney
 
Turning Development Outside-In
Turning Development Outside-InTurning Development Outside-In
Turning Development Outside-InKevlin Henney
 
Giving Code a Good Name
Giving Code a Good NameGiving Code a Good Name
Giving Code a Good NameKevlin Henney
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantKevlin Henney
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our WaysKevlin Henney
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersKevlin Henney
 
SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID DeconstructionKevlin Henney
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that WordKevlin Henney
 

More from Kevlin Henney (20)

Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical Excellence
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical Development
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Get Kata
Get KataGet Kata
Get Kata
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
 
Agility ≠ Speed
Agility ≠ SpeedAgility ≠ Speed
Agility ≠ Speed
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
Turning Development Outside-In
Turning Development Outside-InTurning Development Outside-In
Turning Development Outside-In
 
Giving Code a Good Name
Giving Code a Good NameGiving Code a Good Name
Giving Code a Good Name
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation Quadrant
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
 
Software Is Details
Software Is DetailsSoftware Is Details
Software Is Details
 
Game of Sprints
Game of SprintsGame of Sprints
Game of Sprints
 
Good Code
Good CodeGood Code
Good Code
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our Ways
 
Seven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many ProgrammersSeven Ineffective Coding Habits of Many Programmers
Seven Ineffective Coding Habits of Many Programmers
 
SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID Deconstruction
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that Word
 

Recently uploaded

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 

Recently uploaded (20)

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 

Lambda? You Keep Using that Letter

  • 1. Lambda?You Keep Using that Letter @KevlinHenney
  • 2.
  • 5.
  • 6. We do not attach any character of uniqueness or absolute truth to any particular system of logic.
  • 7. 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.
  • 8.
  • 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 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/
  • 11.
  • 12. We demand rigidly defined areas of doubt and uncertainty!
  • 13.
  • 14. 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
  • 15. There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  • 16. There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton
  • 17.
  • 18. 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.
  • 19. And we define the word formula to mean any finite sequence of symbols out of this list.
  • 21. f → λ x· formula
  • 22. f → λ x· y x variable abstraction application
  • 23. f → λ x· y x abbreviation free variable bound variable
  • 25. square → λ x· x × x
  • 26. square → λ 😠· 😠 × 😠
  • 27. ☐ → λ 😠· 😠 × 😠
  • 28. ☐ 7
  • 30. (λ x· x × x) 7
  • 31.
  • 34.
  • 35. 0
  • 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. 7
  • 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 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
  • 50. auto square = [](auto x) { return x * x; };
  • 53. [](auto x) {return x * x;}(7)
  • 54. 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
  • 55. Excel is the world’s most popular functional language Simon Peyton-Jones
  • 56.
  • 57. (lambda (x) (* x x))
  • 58. ((lambda (x) (* x x)) 7)
  • 62. http://xkcd.com/224/ We lost the documentation on quantum mechanics. You'll have to decode the regexes yourself.
  • 63.
  • 64. (int x) int: x * x
  • 65. proc (int) int square; square := (int x) int: x * x; int result := square (7);
  • 66. ((int x) int: x * x) (7)
  • 67. 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
  • 68. 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
  • 69. 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)
  • 70. 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)
  • 71. 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)
  • 72. 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
  • 73.
  • 74. (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))))
  • 75. (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))))
  • 76. 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
  • 77. 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
  • 78. 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
  • 79. At that moment, Anton became enlightened. http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html
  • 80.
  • 81. λ-calculus was the first object-oriented language.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92. 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”
  • 93. begin ref(Rock) array items(1:capacity); integer count; integer procedure Depth; ... ref(Rock) procedure Top; ... procedure Push(top); ... procedure Pop; ... count := 0 end;
  • 94. 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”
  • 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, 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
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103. lambda
  • 105. fn
  • 106.
  • 107. =>
  • 108. ->
  • 109. []
  • 110. [](){}
  • 112.
  • 114. f → λ x· y x variable abstraction application
  • 115. [](auto x) {return x * x;}(7) abstraction variable application
  • 116.
  • 117. “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.
  • 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 = [](auto n) { return [=](auto f) { return [=](auto x) { return f(n(f)(x)); }; }; };
  • 123. auto _0 = [](auto f) { 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. _0
  • 129. auto plus_1 = [](auto n) { return n + lexical_cast<decltype(n)>(1); };
  • 132. square
  • 133. auto square = [](auto m) { return _2(m); };
  • 137. 49
  • 138.
  • 140. true → λ a b· a false → λ a b· b
  • 141.
  • 142. 7 * 7 < limit ifTrue: [^ ‘👍’] ifFalse: [^ ‘👎’]
  • 143. True ifTrue: toDo ifFalse: ignore ^ toDo value
  • 144. False ifTrue: ignore ifFalse: toDo ^ toDo value
  • 145. false → λ a b· b
  • 146. false → λ 🙂☹· ☹
  • 147. false → λ f x· x
  • 149.
  • 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
  • 153.
  • 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
  • 156.
  • 157.
  • 158. People who brook no compromise in programming languages should program in lambda calculus or machine language. Andrew Koenig