mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
bugfix in Gen; make API change explicit for Gen.merge
This commit is contained in:
parent
48ef226efd
commit
2936595dbb
3 changed files with 6 additions and 6 deletions
2
gen.ml
2
gen.ml
|
|
@ -955,7 +955,7 @@ let product gena genb =
|
||||||
| `Stop -> None
|
| `Stop -> None
|
||||||
| `GetLeft ->
|
| `GetLeft ->
|
||||||
begin match gena() with
|
begin match gena() with
|
||||||
| None -> cur := `GetRight
|
| None -> cur := `GetRightOrStop
|
||||||
| Some a -> all_a := a :: !all_a; cur := `ProdLeft (a, !all_b)
|
| Some a -> all_a := a :: !all_a; cur := `ProdLeft (a, !all_b)
|
||||||
end;
|
end;
|
||||||
next ()
|
next ()
|
||||||
|
|
|
||||||
8
gen.mli
8
gen.mli
|
|
@ -192,11 +192,11 @@ module type S = sig
|
||||||
|
|
||||||
val merge : 'a gen t -> 'a t
|
val merge : 'a gen t -> 'a t
|
||||||
(** Pick elements fairly in each sub-generator. The merge of enums
|
(** Pick elements fairly in each sub-generator. The merge of enums
|
||||||
[e1, e2, ... en] picks one element in [e1], then one element in [e2],
|
[e1, e2, ... ] picks elements in [e1], [e2],
|
||||||
then in [e3], ..., then in [en], and then starts again at [e1]. Once
|
in [e3], [e1], [e2] .... Once a generator is empty, it is skipped;
|
||||||
a generator is empty, it is skipped; when they are all empty,
|
when they are all empty, and none remains in the input,
|
||||||
their merge is also empty.
|
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
|
val intersection : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t -> 'a t
|
||||||
(** Intersection of two sorted sequences. Only elements that occur in both
|
(** Intersection of two sorted sequences. Only elements that occur in both
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ let test_filterMap () =
|
||||||
let test_merge () =
|
let test_merge () =
|
||||||
let e = Gen.of_list [1--3; 4--6; 7--9] in
|
let e = Gen.of_list [1--3; 4--6; 7--9] in
|
||||||
let e' = Gen.merge e 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 () =
|
let test_persistent () =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue