Stdlib320.StringA module containing basic string operations
Creates a string based on an index function, i.e., init n f is a string of length n whose ith character is f i
let _ = assert (init 3 (fun x -> char_of_int (x + 65)) = "ABC")
let _ = assert (init 5 (fun _ -> 'z') = "zzzzz")length s is the number of characters in s
let _ = assert (length "ABC" = 3)Gets the character in a string at a given index, i.e., get s i is the ith character of s. It's equivalent to writing s.[i]
Raises an Invalid_argument exception if i < 0 and i >= length s
Combines a list of string with a given delimiter
let _ = assert (concat "," ["A";"B";"C"] = "A,B,C")
let _ = assert (concat "" ["1";"2";"3"] = "123")Removes whitespace from the beginning and end of its argument
let _ = assert (" xyz \n" = "xyz")Gets a substring, i.e., sub s p l is the substring of s of length l starting at position p, where a position is a value between 0 and length s which marks the beginning of a substring
let _ = assert (sub "ABC" 0 2= "AB")
let _ = assert (sub "ABC" 3 0 = "")
let _ = assert (sub "ABC" 1 1 = "B")Raises an Invalid_argument exception if p < 0 or p + l > length s
These functions work the same as they would on a char list.