aboutsummaryrefslogtreecommitdiffstats
path: root/samples/list.tunk
diff options
context:
space:
mode:
Diffstat (limited to 'samples/list.tunk')
-rw-r--r--samples/list.tunk18
1 files changed, 18 insertions, 0 deletions
diff --git a/samples/list.tunk b/samples/list.tunk
new file mode 100644
index 0000000..be941ba
--- /dev/null
+++ b/samples/list.tunk
@@ -0,0 +1,18 @@
+# Define 2-tuples
+pair a b fn = fn a b;
+first p = p true;
+second p = p false;
+
+# Define Church encoded lists in one-pair-as-a-list-node style
+cons = pair;
+head = first;
+tail = second;
+nil = false;
+_a x y z = false;
+isnil l = l _a true;
+
+# Test them out
+list1 = cons "1" nil;
+list2 = cons "2" list1;
+list3 = cons "3" list2;
+