From f57d7267ac54ac6f942a74c6da78d034b9f013ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Glen=20M=C3=A9vel?= Date: Mon, 25 Apr 2016 11:39:03 +0200 Subject: [PATCH] bug fix for CCList.range_by --- src/core/CCList.ml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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