Adding String.iteri.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10762 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2010-11-05 08:15:36 +00:00
parent a5628ad725
commit f537ba28b0
3 changed files with 17 additions and 0 deletions

View File

@ -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
[] -> ""

View File

@ -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

View File

@ -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