summaryrefslogtreecommitdiffstats
path: root/camlp4/examples/lambda_test.ml
blob: e2603259a15ae9350f62c5487e13cbff1b079c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
let id = << fun x -> x >>
(* Imported and traduced from CCT *)
let zero = << fun s -> fun z -> z >>
let succ = << fun n -> fun s -> fun z -> s n >>
let one = << $succ$ $zero$ >>
let iota = << fun x -> z >>
let rho = << fun m -> fun r -> (s m (m r $iota$ r)) >>
let rec_nat =
  << fun n -> fun s -> fun z -> n $rho$ $iota$ $rho$ >>
let plus = << fun n -> fun m -> $rec_nat$ n (fun n -> fun p -> $succ$ p) m >>
let times = << fun n -> fun m -> $rec_nat$ n (fun n -> fun p -> $plus$ m p) $zero$ >>
let fact = << fun n -> $rec_nat$ n (fun n -> fun p -> $times$ ($succ$ n) p) $one$ >>