next up previous contents index search.gif
Next: 6.4 Value typecasts Up: 6. Expressions Previous: 6.2 Function calls

6.3 Set constructors

When you want to enter a set-type constant in an expression, you must give a set constructor. In essence this is the same thing as when you define a set type, only you have no identifier to identify the set with. A set constructor is a comma separated list of expressions, enclosed in square brackets.

Set constructors

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{set\ constru...
...h}
\<[b] \synt{set\ group} \\ \lit* , \>
\end{displaymath}\lit* ]\end{syntdiag}

\begin{syntdiag}\setlength {\sdmidskip}{.5em}\sffamily\sloppy \synt{set\ group} ...
...\begin{displaymath}
\lit* {..} \synt{expression}
\end{displaymath}\end{syntdiag}
All set groups and set elements must be of the same ordinal type. The empty set is denoted by [], and it can be assigned to any type of set. A set group with a range [A..Z] makes all values in the range a set element. If the first range specifier has a bigger ordinal value than the second the set is empty, e.g., [Z..A] denotes an empty set. The following are valid set constructors:

[today,tomorrow]
[Monday..Friday,Sunday]
[ 2, 3*2, 6*2, 9*2 ]
['A'..'Z','a'..'z','0'..'9']


root
1999-06-10