STRING
signatureThe STRING signature specifies the basic operations on a string type, which is a vector of the underlying character type char as defined in the substructure Char.
The STRING signature is matched by two structures, the required String and the optional WideString. The former implements strings based on 8-bit characters. The latter provides strings of characters of some size greater than or equal to 8 bits. In particular, structure String.Char is identical to the structure Char and, when defined, the structure WideString.Char is identical to WideChar. In addition, the type String.string is identical to CharVector.vector, and the type WideString.string is identical to WideCharVector.vector.
signature STRING
structure String
: STRING
structure WideString
: STRING
eqtype string
structure Char : CHAR
val maxSize : int
val size : string -> int
val sub : (string * int) -> Char.char
val extract : (string * int * int option) -> string
val substring : (string * int * int) -> string
val concat : string list -> string
val ^ : (string * string) -> string
val str : Char.char -> string
val implode : Char.char list -> string
val explode : string -> Char.char list
val map : (Char.char -> Char.char) -> string -> string
val translate : (Char.char -> string) -> string -> string
val tokens : (Char.char -> bool) -> string -> string list
val fields : (Char.char -> bool) -> string -> string list
val isPrefix : string -> string -> bool
val compare : (string * string) -> order
val collate : ((Char.char * Char.char) -> order) -> (string * string) -> order
val < : (string * string) -> bool
val <= : (string * string) -> bool
val > : (string * string) -> bool
val >= : (string * string) -> bool
val fromString : String.string -> string option
val toString : string -> String.string
val fromCString : String.string -> string option
val toCString : string -> String.string
eqtype string
structure Char
maxSize
size s
sub (s, i)
size
s <= i.
extract (s, i, NONE)
extract (s, i, SOME j)
substring (s, i, j)
s[i..size s-1]
. This raises Subscript if i < 0
or size s < i
. The second form returns the substring of length j starting at index i, i.e., the string s[i..i+j-1]
. It raises Subscript if i < 0 or j < 0 or size
s < i + j. Note that, if defined, extract returns the empty string when i = size s
.
The third form returns the substring of length j starting at index i, i.e., the string s[i..i+j-1]
. This is equivalent to extract(s, i, SOME j)
.
Implementation note:
Note that implementations of these functions must perform bounds checking in such a way that the Overflow exception is not raised.
concat l
s ^ t
size
s + size
t > maxSize
.
str c
implode l
concat (List.map str l)
.
explode s
map f s
implode(List.map f (explode s))
.
translate f s
concat(List.map f (explode s))
.
tokens p s
fields p s
Two tokens may be separated by more than one delimiter, whereas two fields are separated by exactly one delimiter. For example, if the only delimiter is the character #"|"
, then the string "|abc||def"
contains two tokens "abc"
and "def"
, whereas it contains the four fields ""
, "abc"
, ""
and "def"
.
isPrefix s1 s2
true
if the string s1 is a prefix of the string s2.
compare (s, t)
collate f (s, t)
s < t
s <= t
s > t
s >= t
fromString s
toString s
fromCString s
toCString s
CHAR, SUBSTRING, StringCvt, MultiByte, CharVector, CharArray, WideCharVector
Last Modified January 21, 1997
Copyright © 1996 AT&T