mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
deprecate CCList.split, introduce CCList.take_drop instead.
This commit is contained in:
parent
3d035e05cd
commit
bd6940afbf
2 changed files with 9 additions and 5 deletions
|
|
@ -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 )
|
||||
*)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue