summaryrefslogtreecommitdiffstats
path: root/camlp4/examples/lambda_test.ml
diff options
context:
space:
mode:
Diffstat (limited to 'camlp4/examples/lambda_test.ml')
-rw-r--r--camlp4/examples/lambda_test.ml13
1 files changed, 13 insertions, 0 deletions
diff --git a/camlp4/examples/lambda_test.ml b/camlp4/examples/lambda_test.ml
new file mode 100644
index 000000000..746aea445
--- /dev/null
+++ b/camlp4/examples/lambda_test.ml
@@ -0,0 +1,13 @@
+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$ >>
+