summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2010-11-05 08:15:36 +0000
committerAlain Frisch <alain@frisch.fr>2010-11-05 08:15:36 +0000
commitf537ba28b044ee7c4ea9d05e3934c9146e079cc1 (patch)
treed9c06dc96b017ad80ebb38929b88f91ced9b0a9a /stdlib
parenta5628ad72587ecef6e117b7436d49935638beab9 (diff)
downloadocaml-f537ba28b044ee7c4ea9d05e3934c9146e079cc1.tar.gz
Adding String.iteri.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10762 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/string.ml3
-rw-r--r--stdlib/string.mli7
-rw-r--r--stdlib/stringLabels.mli7
3 files changed, 17 insertions, 0 deletions
diff --git a/stdlib/string.ml b/stdlib/string.ml
index 0cb67d289f..e61e9efe90 100644
--- a/stdlib/string.ml
+++ b/stdlib/string.ml
@@ -60,6 +60,9 @@ let blit s1 ofs1 s2 ofs2 len =
let iter f a =
for i = 0 to length a - 1 do f(unsafe_get a i) done
+let iteri f a =
+ for i = 0 to length a - 1 do f i (unsafe_get a i) done
+
let concat sep l =
match l with
[] -> ""
diff --git a/stdlib/string.mli b/stdlib/string.mli
index 21bfb7c0e1..a2d995df24 100644
--- a/stdlib/string.mli
+++ b/stdlib/string.mli
@@ -94,6 +94,13 @@ val iter : (char -> unit) -> string -> unit
the characters of [s]. It is equivalent to
[f s.[0]; f s.[1]; ...; f s.[String.length s - 1]; ()]. *)
+val iteri : (int -> char -> unit) -> string -> unit
+(** Same as {!String.iter}, but the
+ function is applied to the index of the element as first argument (counting from 0),
+ and the character itself as second argument.
+ @since 3.13.0
+*)
+
val escaped : string -> string
(** Return a copy of the argument, with special characters
represented by escape sequences, following the lexical
diff --git a/stdlib/stringLabels.mli b/stdlib/stringLabels.mli
index 9cbee708bb..d1a3966f57 100644
--- a/stdlib/stringLabels.mli
+++ b/stdlib/stringLabels.mli
@@ -84,6 +84,13 @@ val iter : f:(char -> unit) -> string -> unit
the characters of [s]. It is equivalent to
[f s.[0]; f s.[1]; ...; f s.[String.length s - 1]; ()]. *)
+val iteri : f:(int -> char -> unit) -> string -> unit
+(** Same as {!String.iter}, but the
+ function is applied to the index of the element as first argument (counting from 0),
+ and the character itself as second argument.
+ @since 3.13.0
+*)
+
val escaped : string -> string
(** Return a copy of the argument, with special characters
represented by escape sequences, following the lexical