From 4781e0b7e2bae0820378c14d72003f7107cc2b4b Mon Sep 17 00:00:00 2001 From: Fardale Date: Wed, 25 Dec 2024 19:33:40 +0100 Subject: [PATCH] CCInt(chore): conditionally define function existing in newer OCaml --- src/core/CCInt.ml | 4 ++++ src/core/CCInt.mli | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 7cf914c8..801b0857 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -102,9 +102,13 @@ end include Infix +[@@@iflt 4.13] + let min : t -> t -> t = Stdlib.min let max : t -> t -> t = Stdlib.max +[@@@endif] + let floor_div a n = if a < 0 && n >= 0 then ((a + 1) / n) - 1 diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index fb12bb90..525d8bf0 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -59,6 +59,8 @@ val to_string_binary : t -> string (** [to_string_binary x] returns the string representation of the integer [x], in binary. @since 0.20 *) +[@@@iflt 4.13] + val min : t -> t -> t (** [min x y] returns the minimum of the two integers [x] and [y]. @since 0.17 *) @@ -67,6 +69,8 @@ val max : t -> t -> t (** [max x y] returns the maximum of the two integers [x] and [y]. @since 0.17 *) +[@@@endif] + val range_by : step:t -> t -> t -> t iter (** [range_by ~step i j] iterates on integers from [i] to [j] included, where the difference between successive elements is [step].