Add simple 'switch' implemented in pbl
This commit is contained in:
parent
77c9c39295
commit
166c9d4889
|
@ -18,3 +18,15 @@
|
||||||
|
|
||||||
; Return the smaller of the two
|
; Return the smaller of the two
|
||||||
(def min (fn (a b) (if (< a b) a b)))
|
(def min (fn (a b) (if (< a b) a b)))
|
||||||
|
|
||||||
|
(def switch (fn (pair_list)
|
||||||
|
(if (= 0 (len pair_list))
|
||||||
|
"no match"
|
||||||
|
(
|
||||||
|
(def _pair (at 0 pair_list))
|
||||||
|
(if (at 0 _pair)
|
||||||
|
(at 1 _pair)
|
||||||
|
(switch (rest pair_list))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
))
|
||||||
|
|
Loading…
Reference in New Issue