From 4a2d4f52b520d2ce4a75d0426d8f3d851afafd0c Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 4 Mar 2019 15:44:30 -0500 Subject: [PATCH] Allow inverted ranges with negative steps. --- src/core/core.janet | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/core.janet b/src/core/core.janet index 84cab34b..a8b24f55 100644 --- a/src/core/core.janet +++ b/src/core/core.janet @@ -697,9 +697,9 @@ arr) 3 (do (def [n m s] args) - (def arr (array/new (math/ceil (/ n s)))) - (loop [i :range [n m s]] (array/push arr i)) - arr) + (if (neg? s) + (seq [i :down [n m (- s)]] i) + (seq [i :range [n m s]] i))) (error "expected 1 to 3 arguments to range"))) (defn find-index @@ -1531,7 +1531,7 @@ value, one key will be ignored." (var pindex 0) (var pstatus nil) (def len (length buf)) - (when (= len 0) + (when (= len 0) (parser/eof p) (set going false)) (while (> len pindex)