Better switch functionality.

This commit is contained in:
Sage Vaillancourt 2021-12-15 14:39:13 -05:00 committed by Sage Vaillancourt
parent 55d39431b1
commit f3a69989fa
1 changed files with 3 additions and 4 deletions

View File

@ -28,10 +28,9 @@
; Switch expression
; Doesn't yet work with lambdas
(def switch (fn (val pair_list)
(if (= 0 (len pair_list)) "no match" (
(def current (at 0 pair_list))
(if (= val (at 0 current)) (at 1 current) (
(if (= 0 (len pair_list)) "no match"
(if (= val (at 0 (at 0 pair_list))) (at 1 (at 0 pair_list)) (
(switch val (rest pair_list))
))
))
)
))