bugfix in Gen; make API change explicit for Gen.merge

This commit is contained in:
Simon Cruanes 2014-01-30 01:49:01 +01:00
parent 48ef226efd
commit 2936595dbb
3 changed files with 6 additions and 6 deletions

2
gen.ml
View file

@ -955,7 +955,7 @@ let product gena genb =
| `Stop -> None
| `GetLeft ->
begin match gena() with
| None -> cur := `GetRight
| None -> cur := `GetRightOrStop
| Some a -> all_a := a :: !all_a; cur := `ProdLeft (a, !all_b)
end;
next ()

View file

@ -192,11 +192,11 @@ module type S = sig
val merge : 'a gen t -> 'a t
(** Pick elements fairly in each sub-generator. The merge of enums
[e1, e2, ... en] picks one element in [e1], then one element in [e2],
then in [e3], ..., then in [en], and then starts again at [e1]. Once
a generator is empty, it is skipped; when they are all empty,
[e1, e2, ... ] picks elements in [e1], [e2],
in [e3], [e1], [e2] .... Once a generator is empty, it is skipped;
when they are all empty, and none remains in the input,
their merge is also empty.
For instance, [merge [1;3;5] [2;4;6]] will be [1;2;3;4;5;6]. *)
For instance, [merge [1;3;5] [2;4;6]] will be, in disorder, [1;2;3;4;5;6]. *)
val intersection : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t -> 'a t
(** Intersection of two sorted sequences. Only elements that occur in both

View file

@ -56,7 +56,7 @@ let test_filterMap () =
let test_merge () =
let e = Gen.of_list [1--3; 4--6; 7--9] in
let e' = Gen.merge e in
OUnit.assert_equal [1;4;7;2;5;8;3;6;9] (Gen.to_list e');
OUnit.assert_equal [1;2;3;4;5;6;7;8;9] (Gen.to_list e' |> List.sort compare);
()
let test_persistent () =