aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/SYMBOL.ht
blob: da25d20c3929936e1f5cc61c5dbe46e78b725774 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\SymbolXmpTitle}{Symbol}
\newcommand{\SymbolXmpNumber}{9.79}
%
% =====================================================================
\begin{page}{SymbolXmpPage}{9.79 Symbol}
% =====================================================================
\beginscroll
 
Symbols are one of the basic types manipulated by \Language{}.
The \spadtype{Symbol} domain provides ways to create
symbols of many varieties.
\showBlurb{Symbol}
 
\xtc{
The simplest way to create a symbol is to ``single quote'' an identifier.
%-% \HDindex{quote}{SymbolXmpPage}{9.79}{Symbol}
}{
\spadpaste{X: Symbol := 'x \bound{X}}
}
\xtc{
This gives the symbol even if \spad{x} has been assigned a value.
If \spad{x} has not been assigned a value, then it is possible to omit
the quote.
}{
\spadpaste{XX: Symbol := x}
}
\xtc{
Declarations must be used when working
with symbols, because otherwise the interpreter tries to place
values in a more specialized type \spadtype{Variable}.
}{
\spadpaste{A := 'a}
}
\xtc{
}{
\spadpaste{B := b}
}
\xtc{
The normal way of entering polynomials uses this fact.
}{
\spadpaste{x**2 + 1}
}
 
\xtc{
Another convenient way to create symbols is to convert a string.
This is useful when the name is to be constructed by a program.
}{
\spadpaste{"Hello"::Symbol}
}
\xtc{
Sometimes it is necessary to generate new unique symbols, for example, to
name constants of integration.
The expression \spad{new()} generates a symbol starting with \spad{\%}.
}{
\spadpaste{new()\$Symbol}
}
\xtc{
Successive calls to \spadfunFrom{new}{Symbol} produce different symbols.
}{
\spadpaste{new()\$Symbol}
}
\xtc{
The expression \spad{new("s")} produces a symbol starting with \spad{\%s}.
}{
\spadpaste{new("xyz")\$Symbol}
}
 
\xtc{
A symbol can be adorned in various ways.
The most basic thing is applying a symbol to a list
of subscripts.
}{
\spadpaste{X[i,j] \free{X}}
}
 
\xtc{
Somewhat less pretty is to attach subscripts, superscripts or arguments.
}{
\spadpaste{U := subscript(u, [1,2,1,2]) \bound{U}}
}
\xtc{
}{
\spadpaste{V := superscript(v, [n]) \bound{V}}
}
\xtc{
}{
\spadpaste{P := argscript(p, [t]) \bound{P}}
}
 
\xtc{
It is possible to test whether a symbol has scripts using the
\spadfunFrom{scripted?}{Symbol} test.
}{
\spadpaste{scripted? U \free{U}}
}
\xtc{
}{
\spadpaste{scripted? X \free{X}}
}
\xtc{
If a symbol is not scripted, then it may be converted to a string.
}{
\spadpaste{string X \free{X}}
}
\xtc{
The basic parts can always be extracted using the
\spadfunFrom{name}{Symbol} and \spadfunFrom{scripts}{Symbol} operations.
}{
\spadpaste{name U \free{U}}
}
\xtc{
}{
\spadpaste{scripts U \free{U}}
}
\xtc{
}{
\spadpaste{name X \free{X}}
}
\xtc{
}{
\spadpaste{scripts X \free{X}}
}
 
\xtc{
The most general form is obtained using the \spadfunFrom{script}{Symbol}
operation.
This operation takes an argument which is a list containing, in this order,
lists of subscripts, superscripts, presuperscripts, presubscripts and
arguments to a symbol.
}{
\spadpaste{M := script(Mammoth, [[i,j],[k,l],[0,1],[2],[u,v,w]]) \bound{M}}
}
\xtc{
}{
\spadpaste{scripts M \free{M}}
}
\xtc{
If trailing lists of scripts are omitted, they are assumed to be empty.
}{
\spadpaste{N := script(Nut, [[i,j],[k,l],[0,1]]) \bound{N}}
}
\xtc{
}{
\spadpaste{scripts N \free{N}}
}
\endscroll
\autobuttons
\end{page}
%