aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/STBL.ht
blob: c3b1f79bd6a1fc92260b0e96960dfed672344708 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\SparseTableXmpTitle}{SparseTable}
\newcommand{\SparseTableXmpNumber}{9.73}
%
% =====================================================================
\begin{page}{SparseTableXmpPage}{9.73 SparseTable}
% =====================================================================
\beginscroll
%
The \spadtype{SparseTable} domain provides a general purpose
table type with default entries.
\xtc{
Here we create a table to save strings under integer keys.
The value \spad{"Try again!"} is returned if no other value has been
stored for a key.
}{
\spadpaste{t: SparseTable(Integer, String, "Try again!") := table() \bound{t}}
}
\xtc{
Entries can be stored in the table.
}{
\spadpaste{t.3 := "Number three" \free{t}\bound{t1}}
}
\xtc{
}{
\spadpaste{t.4 := "Number four" \free{t}\bound{t2}}
}
\xtc{
These values can be retrieved as usual, but if a look up fails
the default entry will be returned.
}{
\spadpaste{t.3 \free{t1}}
}
\xtc{
}{
\spadpaste{t.2 \free{t}}
}
\xtc{
To see which values are explicitly stored, the
\spadfunFrom{keys}{SparseTable} and \spadfunFrom{entries}{SparseTable}
functions can be used.
}{
\spadpaste{keys t \free{t1 t2}}
}
\xtc{
}{
\spadpaste{entries t \free{t1 t2}}
}
If a specific table representation
is required, the \spadtype{GeneralSparseTable} constructor should be used.
The domain \spadtype{SparseTable(K, E, dflt)} is equivalent to
\spadtype{GeneralSparseTable(K,E, Table(K,E), dflt)}.
%-% \HDexptypeindex{GeneralSparseTable}{SparseTableXmpPage}{9.73}{SparseTable}
For more information, see
\downlink{`Table'}{TableXmpPage}\ignore{Table} and
\downlink{`GeneralSparseTable'}{GeneralSparseTableXmpPage}\ignore{GeneralSparseTable}.
\showBlurb{SparseTable}
\endscroll
\autobuttons
\end{page}
%