% 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}
%
