% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. % !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. \newcommand{\StringTableXmpTitle}{StringTable} \newcommand{\StringTableXmpNumber}{9.78} % % ===================================================================== \begin{page}{StringTableXmpPage}{9.78 StringTable} % ===================================================================== \beginscroll % This domain provides a table type in which the keys are known to be strings so special techniques can be used. Other than performance, the type \spadtype{StringTable(S)} should behave exactly the same way as \spadtype{Table(String,S)}. See \downlink{`Table'}{TableXmpPage}\ignore{Table} for general information about tables. \showBlurb{StringTable} \xtc{ This creates a new table whose keys are strings. }{ \spadpaste{t: StringTable(Integer) := table() \bound{t}} } \xtc{ The value associated with each string key is the number of characters in the string. }{ \begin{spadsrc}[\free{t}\bound{h}] for s in split("My name is Ian Watt.",char " ") repeat t.s := #s \end{spadsrc} } \xtc{ }{ \spadpaste{for key in keys t repeat output [key, t.key] \free{t h}} } \endscroll \autobuttons \end{page} %