From 2ea2c405746bfa79d3be478f4c8763dd7dd6ac5f Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 26 Sep 2022 14:02:28 +0300 Subject: Add some concept docs --- examples/algebraic-types-concept.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/algebraic-types-concept.lisp (limited to 'examples/algebraic-types-concept.lisp') diff --git a/examples/algebraic-types-concept.lisp b/examples/algebraic-types-concept.lisp new file mode 100644 index 0000000..315a693 --- /dev/null +++ b/examples/algebraic-types-concept.lisp @@ -0,0 +1,19 @@ +(let just (\[a] + ["maybe" "just" a])) +(let nothing (\[] + ["maybe" "nothing"])) + +(let at (\[n seq] + (match seq + [] (nothing) + (match n + 0 (head seq) + (at (- n 1) (tail seq)))))) + +(let from-just (at 2)) +(let kind (at 1)) + +(let m (just 10)) +(match (kind m) + "just" (from-just m) + "nothing" "nothing") -- cgit v1.3