small details

This commit is contained in:
Simon Cruanes 2017-12-15 12:47:55 +01:00
parent c3590de261
commit eace3581f1
2 changed files with 5 additions and 2 deletions

View file

@ -407,7 +407,10 @@ let group_succ_by ?(eq=fun x y -> x = y) seq k =
k l; (* yield group, and start another one *) k l; (* yield group, and start another one *)
cur := [x]); cur := [x]);
(* last list *) (* last list *)
if !cur <> [] then k !cur begin match !cur with
| [] -> ()
| (_::_) as l -> k l
end
(*$R (*$R
[1;2;3;3;2;2;3;4] [1;2;3;3;2;2;3;4]

View file

@ -261,7 +261,7 @@ val sorted : ?cmp:('a -> 'a -> int) -> 'a t -> bool
@since 0.9 *) @since 0.9 *)
val group_succ_by : ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t val group_succ_by : ?eq:('a -> 'a -> bool) -> 'a t -> 'a list t
(** Group equal consecutive elements. (** Group equal consecutive elements. Linear time.
Formerly synonym to [group]. Formerly synonym to [group].
@since 0.6 *) @since 0.6 *)