Skip to content

Commit

Permalink
Add the function "is_singleton"
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris00 committed Nov 19, 2021
1 parent 6380d48 commit 518b6d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src-base/interval_base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module type T = sig

val compare_f: t -> number -> int
val belong : number -> t -> bool
val is_singleton : t -> bool
val is_bounded : t -> bool
val is_entire : t -> bool
val equal : t -> t -> bool
Expand Down Expand Up @@ -431,6 +432,8 @@ module I = struct

let belong x {low; high} = low <= x && x <= high

let is_singleton {low; high} = (low = high)

let is_bounded {low; high} =
neg_infinity < low && high < infinity

Expand Down
5 changes: 5 additions & 0 deletions src-base/interval_base.mli
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ module type T = sig
val belong : number -> t -> bool
(** [belong x a] returns whether [x] ∈ [a]. *)

val is_singleton : t -> bool
(** [is_singleton x] says whether [x] is a ingleton i.e., the two
bounds of [x] are equal.
@since 1.6 *)

val is_bounded : t -> bool
(** [is_bounded x] says whether the interval is bounded, i.e.,
-∞ < [inf(x)] and [sup(x)] < ∞.
Expand Down

0 comments on commit 518b6d1

Please sign in to comment.