diff --git a/src/data/CCIntMap.ml b/src/data/CCIntMap.ml index aba70b84..1a0b26f7 100644 --- a/src/data/CCIntMap.ml +++ b/src/data/CCIntMap.ml @@ -315,6 +315,14 @@ let rec union f t1 t2 = match t1, t2 with check_invariants (inter (fun _ _ x -> x) (of_list l1) (of_list l2))) *) +(* associativity of union *) +(*$Q & ~small:(fun (a,b,c) -> List.(length a + length b + length c)) + Q.(let p = list (pair int int) in triple p p p) (fun (l1,l2,l3) -> \ + let m1 = of_list l1 and m2 = of_list l2 and m3 = of_list l3 in \ + let f _ x y = max x y in \ + equal ~eq:(=) (union f (union f m1 m2) m3) (union f m1 (union f m2 m3))) +*) + (*$R assert_equal ~cmp:(equal ~eq:(=)) ~printer:(CCFormat.to_string (print CCString.print)) (of_list [1, "1"; 2, "2"; 3, "3"; 4, "4"]) @@ -334,7 +342,6 @@ let rec union f t1 t2 = match t1, t2 with equal ~eq:(=) (of_list l) (union (fun _ a _ -> a) (of_list l)(of_list l))) *) -(* TODO fix *) let rec inter f a b = match a, b with | E, _ | _, E -> E | L (k, v), o @@ -369,6 +376,15 @@ let rec inter f a b = match a, b with equal ~eq:(=) (of_list l) (inter (fun _ a _ -> a) (of_list l)(of_list l))) *) +(* associativity of inter *) +(*$Q & ~small:(fun (a,b,c) -> List.(length a + length b + length c)) + Q.(let p = list (pair int int) in triple p p p) (fun (l1,l2,l3) -> \ + let m1 = of_list l1 and m2 = of_list l2 and m3 = of_list l3 in \ + let f _ x y = max x y in \ + equal ~eq:(=) (inter f (inter f m1 m2) m3) (inter f m1 (inter f m2 m3))) +*) + + (* TODO: write tests *) (** {2 Whole-collection operations} *) diff --git a/src/data/CCIntMap.mli b/src/data/CCIntMap.mli index 9d62dc21..7b2b03b5 100644 --- a/src/data/CCIntMap.mli +++ b/src/data/CCIntMap.mli @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (** {1 Map specialized for Int keys} -{b status: unstable} +{b status: stable} @since 0.10 *) type 'a t