3. 3 Useful Tools*
• F#
• Lambda Calculus
• Programming Theory Notation
* Selection bias for programming language related papers
4. Why F# ?
• Standard ML (SML) – does not have guards
• Caml / Ocaml
• Coq
Many authors will use an ML language in the paper’s body.
5. 2 Ideas from ML Languages
• Lists (singly linked lists)
• Pattern Matching (next page)
::X
Deconstruct:
Construct
:
M A S [
]
TailHead
Cons Empty
6. let rec printLoop printState buffer =
match buffer with
| "("::x::")"::tail when notParen x ->
…
printLoop newState tail
| "("::"("::"("::x::tail when notParen x ->
…
parenOffset = (offset + 1)::(offset + 2)::(offset + 3)::parenOffset
…
printLoop newState tail
| x::")"::")"::")"::tail when notParen x ->
…
parenOffset = parenOffset.Tail.Tail.Tail
…
printLoop newState tail
| [] -> ()
7. Lambda Calculus
Syntax
t ::= terms:
x variable
λx.t abstraction
t t application
v ::= values:
λx.t abstraction value
8. λx. x
Ultra concise function representation
1 input
per λ
Everything after the dot is the
function body, what gets emitted
λx. λy. y x
Multipe inputs
require multiple
λs
9. λx. x
λx. λy. y x
This is the identity function.
It emits whatever the input is
The body of this function applies the term
represented by the value “y” to the term
represented by the value “x”
(λx. λy. y x) x (λx. x) What will this emit?
10. (λx. λy. y x) x (λx. x)
(λy. y x) (λx. x)
(λx. x) x
x
Evaluation