Skip to content

Commit

Permalink
feat(mono): add dotted comparison operators for floats
Browse files Browse the repository at this point in the history
closes #196
  • Loading branch information
c-cube committed Mar 29, 2018
1 parent 972a6f2 commit 55e92b4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/CCString.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/monomorphic/CCMonomorphic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@

include Pervasives

let (=.) : float -> float -> bool = (=)
let (<>.) : float -> float -> bool = (<>)
let (<.) : float -> float -> bool = (<)
let (>.) : float -> float -> bool = (>)

This comment has been minimized.

Copy link
@copy

copy Mar 30, 2018

Contributor

>. is syntax used by MetaOCaml, which would break this library for users of MetaOCaml.

This comment has been minimized.

Copy link
@c-cube

c-cube Mar 31, 2018

Author Owner

Ah, bad timing, I released already 😞

let (<=.) : float -> float -> bool = (<=)
let (>=.) : float -> float -> bool = (>=)

let (==) = `Consider_using_CCEqual_physical
let (!=) = `Consider_using_CCEqual_physical
20 changes: 20 additions & 0 deletions src/monomorphic/CCMonomorphic.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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."]

0 comments on commit 55e92b4

Please sign in to comment.