SML/NJ Library Manual


The CharMap structure


Synopsis

signature CHAR_MAP
structure CharMap :> CHAR_MAP

The CharMap structure provides fast, read-only maps from characters to values.


Interface

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

Description

type 'a char_map

mkCharMap {default, bindings}
makes a character map that maps the bound characters to their bindings and maps everything else to the default value. Specifically, if 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
maps the given character.

mapStrChr cm (s, i)
is equivalent to
          mapChr cm (String.sub(s, i)))
          



See Also

Char

[ Top | Parent | Contents | Index | Root ]

Last Modified June 11, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies