diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 8127db8f..cca52301 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -387,12 +387,14 @@ let rec drop n l = match l with | _ when n=0 -> 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.pair (Q.list Q.small_int) Q.int) (fun (l,i) -> \ let i = abs i in \ - let l1, l2 = split i l in \ + let l1, l2 = take_drop i l in \ l1 @ l2 = l ) *) diff --git a/src/core/CCList.mli b/src/core/CCList.mli index 23670121..7f658f28 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -114,11 +114,13 @@ val take : int -> 'a t -> 'a t val drop : int -> 'a t -> 'a t (** drop the [n] first elements, keep the rest *) -val split : int -> 'a t -> 'a t * 'a t -(** [split n l] returns [l1, l2] such that [l1 @ l2 = l] and +val take_drop : int -> 'a t -> 'a t * 'a t +(** [take_drop n l] returns [l1, l2] such that [l1 @ l2 = l] and [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 (** [last n l] takes the last [n] elements of [l] (or less if