mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Renamed predicate parameter of take_while, rtake_while from p to f, aligining it with pre-existing drop_while.
This commit is contained in:
parent
330cba94de
commit
d29ed7ee72
3 changed files with 14 additions and 14 deletions
|
|
@ -585,17 +585,17 @@ let take n s =
|
|||
else
|
||||
s
|
||||
|
||||
let take_while p s =
|
||||
let take_while f s =
|
||||
let i = ref 0 in
|
||||
while !i < String.length s && p (String.unsafe_get s !i) do
|
||||
while !i < String.length s && f (String.unsafe_get s !i) do
|
||||
incr i
|
||||
done;
|
||||
String.sub s 0 !i
|
||||
|
||||
let rtake_while p s =
|
||||
let rtake_while f s =
|
||||
let s_len_pred = String.length s - 1 in
|
||||
let i = ref s_len_pred in
|
||||
while !i >= 0 && p (String.unsafe_get s !i) do
|
||||
while !i >= 0 && f (String.unsafe_get s !i) do
|
||||
decr i
|
||||
done ;
|
||||
if !i < s_len_pred
|
||||
|
|
|
|||
|
|
@ -183,13 +183,13 @@ val take : int -> string -> string
|
|||
@since 0.17 *)
|
||||
|
||||
val take_while : (char -> bool) -> string -> string
|
||||
(** [take_while p s] keeps only the longest prefix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [p c].
|
||||
(** [take_while f s] keeps only the longest prefix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [f c].
|
||||
@since 3.16 *)
|
||||
|
||||
val rtake_while : (char -> bool) -> string -> string
|
||||
(** [rtake_while p s] keeps only the longest suffix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [p c].
|
||||
(** [rtake_while f s] keeps only the longest suffix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [f c].
|
||||
@since 3.16 *)
|
||||
|
||||
val drop : int -> string -> string
|
||||
|
|
|
|||
|
|
@ -193,14 +193,14 @@ val take : int -> string -> string
|
|||
(** [take n s] keeps only the [n] first chars of [s].
|
||||
@since 0.17 *)
|
||||
|
||||
val take_while : p:(char -> bool) -> string -> string
|
||||
(** [take_while ~p s] keeps only the longest prefix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [p c].
|
||||
val take_while : f:(char -> bool) -> string -> string
|
||||
(** [take_while ~f s] keeps only the longest prefix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [f c].
|
||||
@since 3.16 *)
|
||||
|
||||
val rtake_while : p:(char -> bool) -> string -> string
|
||||
(** [rtake_while ~p s] keeps only the longest suffix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [p c].
|
||||
val rtake_while : f:(char -> bool) -> string -> string
|
||||
(** [rtake_while ~f s] keeps only the longest suffix [t] of [s] such that every
|
||||
character [c] in [t] satisfies [f c].
|
||||
@since 3.16 *)
|
||||
|
||||
val drop : int -> string -> string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue