From f1768c649501e736452ca50dca76644e01af0518 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 2 May 2018 19:49:03 -0400 Subject: - List ranges can now be generated backwards. --- stdlib/source/lux/data/coll/list.lux | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'stdlib/source') 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 [ ] +(do-template [ ] [(def: #export ( from to) {#.doc "Generates an inclusive interval of values [from, to]."} (-> (List )) - (if ( to from) - (list& from ( ( from) to)) - (list)))] + (cond ( to from) + (list& from ( ( from) to)) - [i/range Int i/<= i/inc] - [n/range Nat n/<= n/inc] + ( to from) + (list& from ( ( 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) -- cgit v1.2.3