ListFormat
structure
signature LIST_FORMAT
structure ListFormat
: LIST_FORMAT
The ListFormat structure provides simple utilities for converting between lists and their string representations.
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
fmt {init, sep, final, fmt}
[a, b, ..., c]
gets formated as
init ^ (fmt a) ^ sep ^ (fmt b) ^ sep ^ ... ^ sep ^ (fmt c) ^ final
listToString f l
fmt {init="[", sep=",", final="]", fmt=f} l
scan {init, sep, final, scan} re
The format of the list is specified by an expected initial string init, a list item separator sep, an expected terminating string final, and a function scan for scanning a list item. Whitespace is ignored.
When scanning a string, scan
checks for the separator before the terminator, thus if the separator is a prefix of the terminator, the function will not work.
Format, List, StringCvt
Last Modified June 11, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies