Functional Programming & Proofs

back - cont

Illustrations

What are equivalent lambda-expressions ? How to reduce expression and find results ?

let f(x)=1+x in f(2) = ?
let f(x)=1+x in let g(x)=2*x in f(g(2)) = ?
let f x=fun y->x+y in f 1 2 = ?
let f x=fun y->x+y in let g=f 1 in g 2 = ?
let f x=x+1 in let c g h=fun x->g (h x) in c f f 1 = ?

answers

A simple but more concrete illustration ?

let newPerson x y = fun s -> s x y;;
let name p        = p (fun x y ->x);;
name (newPerson "john" 32) = ?
let age p = ?