alias group_succ_by, deprecated group

This commit is contained in:
Simon Cruanes 2015-08-22 23:49:17 +02:00
parent 80e9057a00
commit d6b7131fd8
2 changed files with 11 additions and 2 deletions

View file

@ -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 *)

View file

@ -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