Add simple 'switch' implemented in pbl

This commit is contained in:
Sage Vaillancourt 2021-07-05 01:14:39 -04:00
parent 77c9c39295
commit 166c9d4889
1 changed files with 12 additions and 0 deletions

View File

@ -18,3 +18,15 @@
; Return the smaller of the two
(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))
)
))
))