--- stdlib/set.mli.orig Tue Dec 9 04:11:48 1997 +++ stdlib/set.mli Thu Jun 4 17:41:07 1998 @@ -50,6 +50,8 @@ val add: elt -> t -> t (* [add x s] returns a set containing all elements of [s], plus [x]. If [x] was already in [s], [s] is returned unchanged. *) + val make: elt -> t + (* [make x] returns a set containing only [x] *) val remove: elt -> t -> t (* [remove x s] returns a set containing all elements of [s], except [x]. If [x] was not in [s], [s] is returned unchanged. *) --- stdlib/set.ml.orig Fri Oct 31 07:59:27 1997 +++ stdlib/set.ml Thu Jun 4 17:41:07 1998 @@ -27,6 +27,7 @@ val is_empty: t -> bool val mem: elt -> t -> bool val add: elt -> t -> t + val make: elt -> t val remove: elt -> t -> t val union: t -> t -> t val inter: t -> t -> t @@ -160,6 +161,8 @@ if c = 0 then t else if c < 0 then bal (add x l) v r else bal l v (add x r) + let make x = Node(Empty, x, Empty, 1) + let rec remove x = function Empty -> Empty | Node(l, v, r, _) -> @@ -171,10 +174,16 @@ match (s1, s2) with (Empty, t2) -> t2 | (t1, Empty) -> t1 - | (Node(l1, v1, r1, _), t2) -> - let (l2, _, r2) = split v1 t2 in - join (union l1 l2) v1 (union r1 r2) - + | ((Node(l1, v1, r1, h1) as t1), (Node(l2, v2, r2, h2) as t2)) -> + if (h1>=h2) then + if (h2=1) then add v2 t1 else + let (l2, _, r2) = split v1 t2 in + join (union l1 l2) v1 (union r1 r2) + else + if (h1=1) then add v1 t2 else + let (l1, _, r1) = split v2 t1 in + join (union l1 l2) v2 (union r1 r2) + let rec inter s1 s2 = match (s1, s2) with (Empty, t2) -> Empty