mirror of
https://github.com/c-cube/iter.git
synced 2025-12-05 19:00:31 -05:00
alias group_succ_by, deprecated group
This commit is contained in:
parent
80e9057a00
commit
d6b7131fd8
2 changed files with 11 additions and 2 deletions
|
|
@ -238,7 +238,7 @@ let sort ?(cmp=Pervasives.compare) seq =
|
|||
let l = List.fast_sort cmp l in
|
||||
fun k -> List.iter k l
|
||||
|
||||
let group ?(eq=fun x y -> x = y) seq k =
|
||||
let group_succ_by ?(eq=fun x y -> x = y) seq k =
|
||||
let cur = ref [] in
|
||||
seq (fun x ->
|
||||
match !cur with
|
||||
|
|
@ -251,6 +251,8 @@ let group ?(eq=fun x y -> x = y) seq k =
|
|||
(* last list *)
|
||||
if !cur <> [] then k !cur
|
||||
|
||||
let group = group_succ_by
|
||||
|
||||
let uniq ?(eq=fun x y -> x = y) seq k =
|
||||
let has_prev = ref false
|
||||
and prev = ref (Obj.magic 0) in (* avoid option type, costly *)
|
||||
|
|
|
|||
|
|
@ -215,7 +215,14 @@ val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a t -> 'a t
|
|||
(** Sort the sequence and remove duplicates. Eager, same as [sort] *)
|
||||
|
||||
val group : ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t
|
||||
(** Group equal consecutive elements. *)
|
||||
(** Group equal consecutive elements.
|
||||
@deprecated use {!group_succ_by} *)
|
||||
|
||||
val group_succ_by : ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t
|
||||
(** Group equal consecutive elements.
|
||||
Synonym to {!group}.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
|
||||
val uniq : ?eq:('a -> 'a -> bool) -> 'a t -> 'a t
|
||||
(** Remove consecutive duplicate elements. Basically this is
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue