mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 11:45:31 -05:00
deprecate CCVector.flat_map', renamed flat_map_seq; add flat_map_list
This commit is contained in:
parent
3a21aab9c8
commit
8e85872beb
2 changed files with 25 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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} *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue