Commit 3efe72c3 authored by POTTIER Francois's avatar POTTIER Francois

Added [Atom.Set.disjoint_union].

parent 6f4371d8
......@@ -139,6 +139,19 @@ module Set = struct
include Set.Make(Order)
(* Disjoint union. *)
exception NonDisjointUnion of atom
let disjoint_union xs ys =
match choose (inter xs ys) with
| exception Not_found ->
(* The intersection of [xs] and [ys] is empty. Return their union. *)
union xs ys
| x ->
(* The intersection contains [x]. Raise an exception. *)
raise (NonDisjointUnion x)
(* Sets of atoms form a monoid under union. *)
class ['z] monoid = object
......
......@@ -28,6 +28,11 @@ val hash: atom -> int
module Set : sig
include Set.S with type elt = atom
(* Disjoint union. *)
exception NonDisjointUnion of atom
val disjoint_union: t -> t -> t
(* Sets of atoms form a monoid under union. *)
class ['z] monoid : object
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment