fixes and format

This commit is contained in:
Simon Cruanes 2024-11-15 11:02:38 -05:00
parent 8d8f1d4145
commit 6dcaddb7c6
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
4 changed files with 11 additions and 7 deletions

View file

@ -1051,8 +1051,8 @@ let all_ok l =
let split_result results = let split_result results =
results results
|> partition_filter_map (fun x -> |> partition_filter_map (fun x ->
match x with match x with
| Ok o -> `Left o | Ok o -> `Left o
| Error e -> `Right e) | Error e -> `Right e)
let group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l = let group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l =

View file

@ -498,7 +498,7 @@ val all_ok : ('a, 'err) result t -> ('a t, 'err) result
val split_result : ('ok, 'error) result list -> 'ok list * 'error list val split_result : ('ok, 'error) result list -> 'ok list * 'error list
(** Split a list of results into [Ok]s and [Error]s. (** Split a list of results into [Ok]s and [Error]s.
@since NEXT_RELEASE *) @since NEXT_RELEASE *)
val sorted_mem : cmp:('a -> 'a -> int) -> 'a -> 'a list -> bool 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], (** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l],
but potentially more efficiently. but potentially more efficiently.

View file

@ -529,6 +529,10 @@ val all_ok : ('a, 'err) result t -> ('a t, 'err) result
@since 1.3, but only @since 1.3, but only
@since 2.2 with labels *) @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)[@keep_label]) -> 'a -> 'a list -> bool val sorted_mem : cmp:(('a -> 'a -> int)[@keep_label]) -> 'a -> 'a list -> bool
(** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l], (** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l],
but potentially more efficiently. but potentially more efficiently.

View file

@ -247,17 +247,17 @@ module Make (O : Set.OrderedType) = struct
let pp ?(pp_start = fun _ () -> ()) ?(pp_stop = fun _ () -> ()) let pp ?(pp_start = fun _ () -> ()) ?(pp_stop = fun _ () -> ())
?(pp_sep = fun fmt () -> Format.fprintf fmt ",@ ") pp_x fmt m = ?(pp_sep = fun fmt () -> Format.fprintf fmt ",@ ") pp_x fmt m =
let rec pp_mult ?(first = true) x n = let rec pp_mult ?(first = true) x n =
if n = 0 then () if n = 0 then
()
else ( else (
if not first then pp_sep fmt (); if not first then pp_sep fmt ();
pp_x fmt x; pp_x fmt x;
pp_mult ~first:false x (n-1) pp_mult ~first:false x (n - 1)
) )
in in
pp_start fmt (); pp_start fmt ();
let first = ref true in let first = ref true in
iter m iter m (fun x n ->
(fun x n ->
if !first then if !first then
first := false first := false
else else