aboutsummaryrefslogtreecommitdiffstats
path: root/examples/algebraic-types-concept.lisp
blob: 315a693de60f155304180b19ba66a505e7187a5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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")