Better switch functionality.
This commit is contained in:
parent
55d39431b1
commit
f3a69989fa
|
@ -28,10 +28,9 @@
|
||||||
; Switch expression
|
; Switch expression
|
||||||
; Doesn't yet work with lambdas
|
; Doesn't yet work with lambdas
|
||||||
(def switch (fn (val pair_list)
|
(def switch (fn (val pair_list)
|
||||||
(if (= 0 (len pair_list)) "no match" (
|
(if (= 0 (len pair_list)) "no match"
|
||||||
(def current (at 0 pair_list))
|
(if (= val (at 0 (at 0 pair_list))) (at 1 (at 0 pair_list)) (
|
||||||
(if (= val (at 0 current)) (at 1 current) (
|
|
||||||
(switch val (rest pair_list))
|
(switch val (rest pair_list))
|
||||||
))
|
))
|
||||||
))
|
)
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue