deprecate CCVector.flat_map', renamed flat_map_seq; add flat_map_list

This commit is contained in:
Simon Cruanes 2015-10-21 14:44:43 +02:00
parent 3a21aab9c8
commit 8e85872beb
2 changed files with 25 additions and 3 deletions

View file

@ -533,15 +533,26 @@ let flat_map f v =
iter (fun x -> iter (push v') (f x)) v;
v'
let flat_map' f v =
let flat_map_seq f v =
let v' = create () in
iter
(fun x ->
let seq = f x in
seq (fun y -> push v' y)
append_seq v' seq;
) v;
v'
let flat_map_list f v =
let v' = create () in
iter
(fun x ->
let l = f x in
append_list v' l;
) v;
v'
let flat_map' = flat_map_seq
let (>>=) x f = flat_map f x
let (>|=) x f = map f x

View file

@ -190,8 +190,19 @@ val filter_map : ('a -> 'b option) -> ('a,_) t -> ('b, 'mut) t
val flat_map : ('a -> ('b,_) t) -> ('a,_) t -> ('b, 'mut) t
(** Map each element to a sub-vector *)
val flat_map_seq : ('a -> 'b sequence) -> ('a,_) t -> ('b, 'mut) t
(** Like {!flat_map}, but using {!sequence} for
intermediate collections.
@since NEXT_RELEASE *)
val flat_map_list : ('a -> 'b list) -> ('a,_) t -> ('b, 'mut) t
(** Like {!flat_map}, but using {!list} for
intermediate collections.
@since NEXT_RELEASE *)
val flat_map' : ('a -> 'b sequence) -> ('a,_) t -> ('b, 'mut) t
(** Like {!flat_map}, but using {!sequence} for intermediate collections *)
(** Alias to {!flat_map_seq}
@deprecated since NEXT_RELEASE , use {!flat_map_seq} *)
val (>>=) : ('a,_) t -> ('a -> ('b,_) t) -> ('b, 'mut) t
(** Infix version of {!flat_map} *)