aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/STRTBL.ht
blob: ec4f6786859652775cc4494831632906cd011066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% 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}
%