]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/camlp4/examples/lambda_test.ml
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / camlp4 / examples / lambda_test.ml
1 let id = << fun x -> x >>
2 (* Imported and traduced from CCT *)
3 let zero = << fun s -> fun z -> z >>
4 let succ = << fun n -> fun s -> fun z -> s n >>
5 let one = << $succ$ $zero$ >>
6 let iota = << fun x -> z >>
7 let rho = << fun m -> fun r -> (s m (m r $iota$ r)) >>
8 let rec_nat =
9   << fun n -> fun s -> fun z -> n $rho$ $iota$ $rho$ >>
10 let plus = << fun n -> fun m -> $rec_nat$ n (fun n -> fun p -> $succ$ p) m >>
11 let times = << fun n -> fun m -> $rec_nat$ n (fun n -> fun p -> $plus$ m p) $zero$ >>
12 let fact = << fun n -> $rec_nat$ n (fun n -> fun p -> $times$ ($succ$ n) p) $one$ >>
13