mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
commit
6d0e2fdd2d
2 changed files with 14 additions and 2 deletions
|
|
@ -51,6 +51,8 @@ module type S = sig
|
||||||
|
|
||||||
val union : t -> t -> t
|
val union : t -> t -> t
|
||||||
|
|
||||||
|
val meet : t -> t -> t
|
||||||
|
|
||||||
val intersection : t -> t -> t
|
val intersection : t -> t -> t
|
||||||
|
|
||||||
val diff : t -> t -> t
|
val diff : t -> t -> t
|
||||||
|
|
@ -117,11 +119,19 @@ module Make(O : Set.OrderedType) = struct
|
||||||
M.merge
|
M.merge
|
||||||
(fun x n1 n2 -> match n1, n2 with
|
(fun x n1 n2 -> match n1, n2 with
|
||||||
| None, None -> assert false
|
| None, None -> assert false
|
||||||
| Some n1, None -> Some n1
|
| Some n, None
|
||||||
| None, Some n2 -> Some n2
|
| None, Some n -> Some n
|
||||||
| Some n1, Some n2 -> Some (n1+n2))
|
| Some n1, Some n2 -> Some (n1+n2))
|
||||||
m1 m2
|
m1 m2
|
||||||
|
|
||||||
|
let meet m1 m2 =
|
||||||
|
M.merge
|
||||||
|
(fun _ n1 n2 -> match n1, n2 with
|
||||||
|
| None, None -> assert false
|
||||||
|
| Some n, None | None, Some n -> Some n
|
||||||
|
| Some n1, Some n2 -> Some (Pervasives.max n1 n2))
|
||||||
|
m1 m2
|
||||||
|
|
||||||
let intersection m1 m2 =
|
let intersection m1 m2 =
|
||||||
M.merge
|
M.merge
|
||||||
(fun x n1 n2 -> match n1, n2 with
|
(fun x n1 n2 -> match n1, n2 with
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ module type S = sig
|
||||||
|
|
||||||
val union : t -> t -> t
|
val union : t -> t -> t
|
||||||
|
|
||||||
|
val meet : t -> t -> t
|
||||||
|
|
||||||
val intersection : t -> t -> t
|
val intersection : t -> t -> t
|
||||||
|
|
||||||
val diff : t -> t -> t
|
val diff : t -> t -> t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue