diff options
Diffstat (limited to 'examples/algebraic-types-concept.lisp')
| -rw-r--r-- | examples/algebraic-types-concept.lisp | 19 |
1 files changed, 19 insertions, 0 deletions
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") |
