From 6dcaddb7c6b7544a4991a0e3225c51838fc4ee0e Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 15 Nov 2024 11:02:38 -0500 Subject: [PATCH] fixes and format --- src/core/CCList.ml | 4 ++-- src/core/CCList.mli | 2 +- src/core/CCListLabels.mli | 4 ++++ src/data/CCMultiSet.ml | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index fa82eaeb..75684ce0 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1051,8 +1051,8 @@ let all_ok l = let split_result results = results |> partition_filter_map (fun x -> - match x with - | Ok o -> `Left o + match x with + | Ok o -> `Left o | Error e -> `Right e) let group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l = diff --git a/src/core/CCList.mli b/src/core/CCList.mli index 9182b749..1bf14ae3 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -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 (** 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. diff --git a/src/core/CCListLabels.mli b/src/core/CCListLabels.mli index 952d028c..f0c82317 100644 --- a/src/core/CCListLabels.mli +++ b/src/core/CCListLabels.mli @@ -529,6 +529,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)[@keep_label]) -> '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. diff --git a/src/data/CCMultiSet.ml b/src/data/CCMultiSet.ml index 49776e97..4fd8352a 100644 --- a/src/data/CCMultiSet.ml +++ b/src/data/CCMultiSet.ml @@ -247,17 +247,17 @@ module Make (O : Set.OrderedType) = struct let pp ?(pp_start = fun _ () -> ()) ?(pp_stop = fun _ () -> ()) ?(pp_sep = fun fmt () -> Format.fprintf fmt ",@ ") pp_x fmt m = let rec pp_mult ?(first = true) x n = - if n = 0 then () + if n = 0 then + () else ( if not first then pp_sep fmt (); pp_x fmt x; - pp_mult ~first:false x (n-1) + pp_mult ~first:false x (n - 1) ) in pp_start fmt (); let first = ref true in - iter m - (fun x n -> + iter m (fun x n -> if !first then first := false else