mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-05 19:00:31 -05:00
parent
9cfedad7ba
commit
8d8f1d4145
2 changed files with 11 additions and 0 deletions
|
|
@ -1048,6 +1048,13 @@ let all_ok l =
|
|||
| None -> assert false
|
||||
| Some e -> Error e)
|
||||
|
||||
let split_result results =
|
||||
results
|
||||
|> partition_filter_map (fun x ->
|
||||
match x with
|
||||
| Ok o -> `Left o
|
||||
| Error e -> `Right e)
|
||||
|
||||
let group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l =
|
||||
let module Tbl = Hashtbl.Make (struct
|
||||
type t = k
|
||||
|
|
|
|||
|
|
@ -495,6 +495,10 @@ val all_ok : ('a, 'err) result t -> ('a t, 'err) result
|
|||
@since 1.3, but only
|
||||
@since 2.2 with labels *)
|
||||
|
||||
val split_result : ('ok, 'error) result list -> 'ok list * 'error list
|
||||
(** Split a list of results into [Ok]s and [Error]s.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val sorted_mem : cmp:('a -> 'a -> int) -> 'a -> 'a list -> bool
|
||||
(** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l],
|
||||
but potentially more efficiently.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue