aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/CCLASS.ht
blob: e550aadeac9dad8741a0c38914075bb32e4c38f0 (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
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\CharacterClassXmpTitle}{CharacterClass}
\newcommand{\CharacterClassXmpNumber}{9.9}
%
% =====================================================================
\begin{page}{CharacterClassXmpPage}{9.9 CharacterClass}
% =====================================================================
\beginscroll
 
The \spadtype{CharacterClass} domain allows classes of characters to be
defined and manipulated efficiently.
%-% \HDexptypeindex{Character}{CharacterClassXmpPage}{9.9}{CharacterClass}
 
\xtc{
Character classes can be created by giving either a string or a list
of characters.
}{
\spadpaste{cl1 := charClass [char "a", char "e", char "i", char "o", char "u", char "y"] \bound{cl1}}
}
\xtc{
}{
\spadpaste{cl2 := charClass "bcdfghjklmnpqrstvwxyz" \bound{cl2}}
}
\xtc{
A number of character classes are predefined for convenience.
}{
\spadpaste{digit()}
}
\xtc{
}{
\spadpaste{hexDigit()}
}
\xtc{
}{
\spadpaste{upperCase()}
}
\xtc{
}{
\spadpaste{lowerCase()}
}
\xtc{
}{
\spadpaste{alphabetic()}
}
\xtc{
}{
\spadpaste{alphanumeric()}
}
\xtc{
You can quickly test whether a character belongs to a class.
}{
\spadpaste{member?(char "a", cl1) \free{cl1}}
}
\xtc{
}{
\spadpaste{member?(char "a", cl2) \free{cl2}}
}
\xtc{
Classes have the usual set operations because
the \spadtype{CharacterClass} domain belongs to the category
\spadtype{FiniteSetAggregate(Character)}.
}{
\spadpaste{intersect(cl1, cl2)  \free{cl1 cl2}}
}
\xtc{
}{
\spadpaste{union(cl1,cl2)       \free{cl1 cl2}}
}
\xtc{
}{
\spadpaste{difference(cl1,cl2)  \free{cl1 cl2}}
}
\xtc{
}{
\spadpaste{intersect(complement(cl1),cl2)  \free{cl1 cl2}}
}
\xtc{
You can modify character classes by adding or removing characters.
}{
\spadpaste{insert!(char "a", cl2) \free{cl2}\bound{cl22}}
}
\xtc{
}{
\spadpaste{remove!(char "b", cl2) \free{cl22}\bound{cl23}}
}
 
For more information on related topics, see
\downlink{`Character'}{CharacterXmpPage}\ignore{Character} and
\downlink{`String'}{StringXmpPage}\ignore{String}.
%
\showBlurb{CharacterClass}
\endscroll
\autobuttons
\end{page}
%