diff options
author | Eduardo Julian | 2018-05-02 19:49:03 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-02 19:49:03 -0400 |
commit | f1768c649501e736452ca50dca76644e01af0518 (patch) | |
tree | 6c109df6835f6626841f4ecd08d3c08f75d104ce /stdlib/source | |
parent | 0c38ade25c2b7f4456ed29b22b2585b407097311 (diff) |
- List ranges can now be generated backwards.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/coll/list.lux | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index b9b743b2c..f6c19dcb9 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -303,16 +303,21 @@ xs')] ($_ compose (sort < pre) (list x) (sort < post))))) -(do-template [<name> <type> <comp> <inc>] +(do-template [<name> <type> <lt> <inc> <gt> <dec>] [(def: #export (<name> from to) {#.doc "Generates an inclusive interval of values [from, to]."} (-> <type> <type> (List <type>)) - (if (<comp> to from) - (list& from (<name> (<inc> from) to)) - (list)))] + (cond (<lt> to from) + (list& from (<name> (<inc> from) to)) - [i/range Int i/<= i/inc] - [n/range Nat n/<= n/inc] + (<gt> to from) + (list& from (<name> (<dec> from) to)) + + ## (= to from) + (list from)))] + + [i/range Int i/< i/inc i/> i/dec] + [n/range Nat n/< n/inc n/> n/dec] ) (def: #export (empty? xs) |