deprecate CCList.split, introduce CCList.take_drop instead.

This commit is contained in:
Simon Cruanes 2015-09-11 09:04:28 +02:00
parent 3d035e05cd
commit bd6940afbf
2 changed files with 9 additions and 5 deletions

View file

@ -387,12 +387,14 @@ let rec drop n l = match l with
| _ when n=0 -> l | _ when n=0 -> l
| _::l' -> drop (n-1) l' | _::l' -> drop (n-1) l'
let split n l = take n l, drop n l let take_drop n l = take n l, drop n l
let split = take_drop
(*$Q (*$Q
(Q.pair (Q.list Q.small_int) Q.int) (fun (l,i) -> \ (Q.pair (Q.list Q.small_int) Q.int) (fun (l,i) -> \
let i = abs i in \ let i = abs i in \
let l1, l2 = split i l in \ let l1, l2 = take_drop i l in \
l1 @ l2 = l ) l1 @ l2 = l )
*) *)

View file

@ -114,11 +114,13 @@ val take : int -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t val drop : int -> 'a t -> 'a t
(** drop the [n] first elements, keep the rest *) (** drop the [n] first elements, keep the rest *)
val split : int -> 'a t -> 'a t * 'a t val take_drop : int -> 'a t -> 'a t * 'a t
(** [split n l] returns [l1, l2] such that [l1 @ l2 = l] and (** [take_drop n l] returns [l1, l2] such that [l1 @ l2 = l] and
[length l1 = min (length l) n] *) [length l1 = min (length l) n] *)
(* TODO: deprecate and rename split, it already exists in stdlib *) val split : int -> 'a t -> 'a t * 'a t
(** synonym to {!take_drop}
@deprecated since NEXT_RELEASE: conflict with the {!List.split} standard function *)
val last : int -> 'a t -> 'a t val last : int -> 'a t -> 'a t
(** [last n l] takes the last [n] elements of [l] (or less if (** [last n l] takes the last [n] elements of [l] (or less if