blob: ce2cd03d97a48f846a24bf17642b59444717a1ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
; LIB
(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 map (\[f m]
(match (kind m)
"just" (just (f (from-just m)))
"nothing")))
; TESTING
(let m (just 10))
(match (kind m)
"just" (from-just m)
"nothing" "nothing")
|