From d29ed7ee72c5adc1621a291f78c1fc15966c18ff Mon Sep 17 00:00:00 2001 From: Alexander Lucas Date: Wed, 1 Jan 2025 09:55:26 -0500 Subject: [PATCH] Renamed predicate parameter of `take_while`, `rtake_while` from `p` to `f`, aligining it with pre-existing `drop_while`. --- src/core/CCString.ml | 8 ++++---- src/core/CCString.mli | 8 ++++---- src/core/CCStringLabels.mli | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/CCString.ml b/src/core/CCString.ml index 240f9e06..d6bb8c62 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -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 diff --git a/src/core/CCString.mli b/src/core/CCString.mli index e280c381..9d2a66ee 100644 --- a/src/core/CCString.mli +++ b/src/core/CCString.mli @@ -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 diff --git a/src/core/CCStringLabels.mli b/src/core/CCStringLabels.mli index a3d4f358..0bd3f1d7 100644 --- a/src/core/CCStringLabels.mli +++ b/src/core/CCStringLabels.mli @@ -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