mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
fixed absurd comment;
better product implementation (in case outer is big and outer is empty)
This commit is contained in:
parent
db302adab2
commit
21f499a5f5
2 changed files with 7 additions and 8 deletions
9
enum.ml
9
enum.ml
|
|
@ -399,9 +399,10 @@ let intersperse x enum =
|
|||
(** Cartesian product *)
|
||||
let product a b =
|
||||
fun () ->
|
||||
(* [a] is the outer relation *)
|
||||
let gen_a = a () in
|
||||
try
|
||||
if is_empty a || is_empty b then fun () -> raise EOG
|
||||
else
|
||||
(* [a] is the outer relation *)
|
||||
let gen_a = a () in
|
||||
(* current element of [a] *)
|
||||
let cur_a = ref (gen_a ()) in
|
||||
let gen_b = ref (b ()) in
|
||||
|
|
@ -414,8 +415,6 @@ let product a b =
|
|||
next ()
|
||||
in
|
||||
next
|
||||
with EOG ->
|
||||
raise EOG (* [a] is empty *)
|
||||
|
||||
let permutations enum =
|
||||
failwith "not implemented" (* TODO *)
|
||||
|
|
|
|||
6
enum.mli
6
enum.mli
|
|
@ -109,8 +109,7 @@ val drop : int -> 'a t -> 'a t
|
|||
(** Drop n elements *)
|
||||
|
||||
val filter : ('a -> bool) -> 'a t -> 'a t
|
||||
(** Filter out elements that do not satisfy the predicate. The outer
|
||||
enum must be finite. *)
|
||||
(** Filter out elements that do not satisfy the predicate. *)
|
||||
|
||||
val takeWhile : ('a -> bool) -> 'a t -> 'a t
|
||||
(** Take elements while they satisfy the predicate *)
|
||||
|
|
@ -133,7 +132,8 @@ val zipIndex : 'a t -> (int * 'a) t
|
|||
(** {2 Complex combinators} *)
|
||||
|
||||
val round_robin : 'a t t -> 'a t
|
||||
(** Pick elements fairly in each sub-enum *)
|
||||
(** Pick elements fairly in each sub-enum. The given enum
|
||||
must be finite (not its elements, though). *)
|
||||
|
||||
val persistent : 'a generator -> 'a t
|
||||
(** Store content of the generator in memory, to be able to iterate on it
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue