Module for simple closed intervals over arbitrary types that are ordered correctly using polymorphic compare.
map t ~f
returns create (f l) (f u)
if bounds t = Some (l, u)
, and empty
if
t
is empty. Note that if f l > f u
, the result of map
is empty
, by the
definition of create
.
If one thinks of an interval as a set of points, rather than a pair of its bounds,
then map
is not the same as the usual mathematical notion of mapping f
over that
set. For example, ~f:(fun x -> x * x)
maps the interval
[-1,1]
to
[1,1]
, not to
[0,1]
.
are_disjoint ts
returns true
iff the intervals in ts
are pairwise disjoint.
Returns true iff a given set of intervals would be disjoint if considered as open intervals. i.e., (3,4) and (4,5) would count as disjoint.
create_ending_after ?zone (od1, od2) ~now
returns the smallest interval (t1 t2)
with minimum t2
such that t2 >= now
, to_ofday t1 = od1
, and to_ofday t2 =
od2
. If zone is specified, it is used to translate od1 and od2 into times,
otherwise the machine's time zone is used. It is not guaranteed that contains (t1
t2) now
, which will be false iff there is no interval containing now
with
to_ofday t1 = od1
and to_ofday t2 = od1
.