The ListFormat structure provides some utility functions for converting
lists into strings (and back).
Synopsis
signature LIST_FORMAT
structure ListFormat : LIST_FORMAT
Interface
val fmt : {
init : string,
sep : string,
final : string,
fmt : 'a -> string
} -> 'a list -> string
val listToString : ('a -> string) -> 'a list -> string
val scan : {
init : string,
sep : string,
final : string,
scan : (char, 'b) StringCvt.reader -> ('a, 'b) StringCvt.reader
} -> (char, 'b) StringCvt.reader -> ('a list, 'b) StringCvt.reader
Description
val fmt : { … } -> 'a list -> string-
fmt {init, sep, final, fmt} lstconverts the listlstto a string, whereinitis an initial string,sepis the separator,finalis the final string, andfmtis a function for converting the list elements to strings. For the list value[a, b, …, c], the resulting string will be formatted asinit ^ (fmt a) ^ sep ^ (fmt b) ^ sep ^ ... ^ sep ^ (fmt c) ^ final val listToString : ('a -> string) -> 'a list -> string-
listToString fmt lstreturns a string representinglstusing SML's list notation. In other words, the above expression is equivalent tofmt {init="[", sep=",", final="]", fmt=fmt} lst val scan : { … } -> (char, 'b) StringCvt.reader -> ('a list, 'b) StringCvt.reader-
scan {init, sep, final, scan} getcreturns areaderfor scanning lists of items from a character stream. The resulting reader expects the list to begin with theinitstring, usesepas a separator, and end with thefinalstring. The reader uses thescanargument function to scan individual list elements.
The reader will skip extra whitespace, so to scan a list of items separated by spaces, use the empty string ("") as the separator.