CharMap
structure
signature CHAR_MAP
structure CharMap
:> CHAR_MAP
The CharMap structure provides fast, read-only maps from characters to values.
type 'a char_map
val mkCharMap : {default : 'a, bindings : (string * 'a) list} -> 'a char_map
val mapChr : 'a char_map -> char -> 'a
val mapStrChr : 'a char_map -> (string * int) -> 'a
type 'a char_map
mkCharMap {default, bindings}
c
is a character and (str,v)
is an item in bindings with c
in str
, then c
will be mapped to v
. Otherwise, c
is mapped to default.
Note that the bindings list is processed from left to right, so if a character appears in multiple strings, the binding specified by the rightmost one will be the one used in the map.
mapChr cm c
mapStrChr cm (s, i)
mapChr cm (String.sub(s, i)))
Char
Last Modified June 11, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies