fixed absurd comment;

better product implementation (in case outer is big and outer is empty)
This commit is contained in:
Simon Cruanes 2013-03-19 13:43:02 +01:00
parent db302adab2
commit 21f499a5f5
2 changed files with 7 additions and 8 deletions

View file

@ -399,9 +399,10 @@ let intersperse x enum =
(** Cartesian product *) (** Cartesian product *)
let product a b = let product a b =
fun () -> fun () ->
(* [a] is the outer relation *) if is_empty a || is_empty b then fun () -> raise EOG
let gen_a = a () in else
try (* [a] is the outer relation *)
let gen_a = a () in
(* current element of [a] *) (* current element of [a] *)
let cur_a = ref (gen_a ()) in let cur_a = ref (gen_a ()) in
let gen_b = ref (b ()) in let gen_b = ref (b ()) in
@ -414,8 +415,6 @@ let product a b =
next () next ()
in in
next next
with EOG ->
raise EOG (* [a] is empty *)
let permutations enum = let permutations enum =
failwith "not implemented" (* TODO *) failwith "not implemented" (* TODO *)

View file

@ -109,8 +109,7 @@ val drop : int -> 'a t -> 'a t
(** Drop n elements *) (** Drop n elements *)
val filter : ('a -> bool) -> 'a t -> 'a t val filter : ('a -> bool) -> 'a t -> 'a t
(** Filter out elements that do not satisfy the predicate. The outer (** Filter out elements that do not satisfy the predicate. *)
enum must be finite. *)
val takeWhile : ('a -> bool) -> 'a t -> 'a t val takeWhile : ('a -> bool) -> 'a t -> 'a t
(** Take elements while they satisfy the predicate *) (** Take elements while they satisfy the predicate *)
@ -133,7 +132,8 @@ val zipIndex : 'a t -> (int * 'a) t
(** {2 Complex combinators} *) (** {2 Complex combinators} *)
val round_robin : 'a t t -> 'a t 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 val persistent : 'a generator -> 'a t
(** Store content of the generator in memory, to be able to iterate on it (** Store content of the generator in memory, to be able to iterate on it