diff options
author | Eduardo Julian | 2020-03-04 21:54:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-03-04 21:54:41 -0400 |
commit | a6c0acbf9d5730f238292ac8a53196d98fbbda72 (patch) | |
tree | 4370164766200823751f4527396c9eab4321d617 /stdlib/source/lux/abstract | |
parent | 21777826feb4affa53bf150588b70fc11bb92512 (diff) |
Test for enums + adjustments to Python-generation code.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/abstract/enum.lux | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/stdlib/source/lux/abstract/enum.lux b/stdlib/source/lux/abstract/enum.lux index 27690b286..9f074f7c5 100644 --- a/stdlib/source/lux/abstract/enum.lux +++ b/stdlib/source/lux/abstract/enum.lux @@ -9,13 +9,13 @@ (: (-> e e) succ) (: (-> e e) pred)) -(def: (range' <= succ from to) - (All [a] (-> (-> a a Bit) (-> a a) a a (List a))) - (if (<= to from) - (#.Cons from (range' <= succ (succ from) to)) - #.Nil)) - -(def: #export (range (^open ",@.") from to) +(def: #export (range enum from to) {#.doc "An inclusive [from, to] range of values."} (All [a] (-> (Enum a) a a (List a))) - (range' (order.<= ,@&order) ,@succ from to)) + (let [(^open "/@.") enum + <= (order.<= /@&order)] + (loop [end to + output #.Nil] + (if (<= end from) + (recur (/@pred end) (#.Cons end output)) + output)))) |