feat(mono): add dotted comparison operators for floats

closes #196
This commit is contained in:
Simon Cruanes 2018-03-28 19:53:02 -05:00
parent 972a6f2720
commit 55e92b4629
3 changed files with 30 additions and 2 deletions

View file

@ -696,7 +696,7 @@ let prefix ~pre s =
else (
let rec check i =
if i=len then true
else if String.unsafe_get s i != String.unsafe_get pre i then false
else if not (Char.equal (String.unsafe_get s i) (String.unsafe_get pre i)) then false
else check (i+1)
in
check 0
@ -719,7 +719,7 @@ let suffix ~suf s =
let off = String.length s - len in
let rec check i =
if i=len then true
else if String.unsafe_get s (off+i) != String.unsafe_get suf i then false
else if not (Char.equal (String.unsafe_get s (off+i)) (String.unsafe_get suf i)) then false
else check (i+1)
in
check 0

View file

@ -3,4 +3,12 @@
include Pervasives
let (=.) : float -> float -> bool = (=)
let (<>.) : float -> float -> bool = (<>)
let (<.) : float -> float -> bool = (<)
let (>.) : float -> float -> bool = (>)
let (<=.) : float -> float -> bool = (<=)
let (>=.) : float -> float -> bool = (>=)
let (==) = `Consider_using_CCEqual_physical
let (!=) = `Consider_using_CCEqual_physical

View file

@ -15,5 +15,25 @@ val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int
(** {2 Infix operators for Floats} *)
val (=.) : float -> float -> bool (** @since NEXT_RELEASE *)
val (<>.) : float -> float -> bool (** @since NEXT_RELEASE *)
val (<.) : float -> float -> bool (** @since NEXT_RELEASE *)
val (>.) : float -> float -> bool (** @since NEXT_RELEASE *)
val (<=.) : float -> float -> bool (** @since NEXT_RELEASE *)
val (>=.) : float -> float -> bool (** @since NEXT_RELEASE *)
(** {2 Shadow Dangerous Operators} *)
val (==) : [`Consider_using_CCEqual_physical]
[@@ocaml.deprecated "Please use CCEqual.physical or Pervasives.(==) instead."]
(** @since NEXT_RELEASE *)
val (!=) : [`Consider_using_CCEqual_physical]
[@@ocaml.deprecated "Please use [not CCEqual.physical] or Pervasives.(!=) instead."]