aboutsummaryrefslogtreecommitdiffstats
path: root/samples/list.tunk
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-11-25 22:48:15 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-11-25 22:48:15 +0200
commit6cb14ee73f6bf21d94bfbfebc97c7759ed2107b5 (patch)
tree50c415a97e4ea73d32ed74307aca55e480ffc401 /samples/list.tunk
parent0e7d993c662652d57bef9c197495fc74d4c6facc (diff)
Add builtinsHEADmain
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;
+