diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 975a0861..80b8578f 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -793,23 +793,29 @@ module Idx = struct end let range_by ~step i j = - if step = 0 then raise (Invalid_argument "CCList.range_by"); - let rec up i j acc = - if i>j then acc else up i (j-step) (j::acc) - and down i j acc = - if i 0 then up i j [] else down i j [] + if step = 0 then + raise (Invalid_argument "CCList.range_by") + else if (if step > 0 then i>j else i