Stdlib320.String
Creates a string based on an index function. init n f
is a string of length n
whose i
th character is f i
.
let _ =
let _ = assert (init 3 (fun x -> char_of_int (x + 65)) = "ABC") in
let _ = assert (init 5 (fun _ -> 'z') = "zzzzz") in
()
Gets the character in a given string at a given index. get s i
is the i
th character of s
if i >= 0
and i < length s
. It is equivalent to writing s.[i]
.
Raises an Invalid_argument
exception otherwise.
Combines a list of string with a given delimiter, e.g., concat "," ["A";"B";"C"] = "A,B,C"
These work the same as they would on lists of char, e.g., map f s = List.map f (to_list s)
.
index s c
is the index of the first occurrence of c
in s
.
If c
does not appear in s
, then it raises an Invalid_argument
expection.
Same as the above function, but is None
in the case of failure.
Converts a string to a list of characters, e.g., to_list "ABC" = ['A';'B';'C']