A set constructor denotes a
set-type value. For example,
[5, 6, 7, 8]
denotes the set whose members are 5, 6, 7,
and 8. The set constructor
[ 5..8 ]
could also denote the same set.
The syntax for a set constructor
is
[ item1, ..., itemn
]
where each item is either an
expression denoting an ordinal of the set’s base type or a pair of such
expressions with two dots (..) in between. When an item has the
form x..y, it is shorthand for all the ordinals in the range from x
to y, inclusive; but if x is greater than y, then x..y
denotes nothing and [x..y] is the empty set.
The set constructor [ ] denotes the empty set, while [x]
denotes the set whose only member is the value of x.
Examples of set constructors:
[red, green, MyColor]
[1, 5, 10..K mod 12, 23]
['A'..'Z', 'a'..'z', Chr(Digit + 48)]
For more information about sets, see Sets.
集合构造器表示集合类型的值。例如:
[5, 6, 7, 8]
表示元素为5、6、7、8的集合。集合构造器
[ 5..8 ]
也表示相同的集合。
集合构造器的语法是
[ item1, ..., itemn
]
这里的每个item,可以是表示集合基类型序数的一个表达式,也可以是两个句点(..)连接的一对这样的表达式。当一个item形如 x..y 时,它是对范围x到y(包括x和y)中所有序数的简写;而如果x大于y,那么x..y表示什么也没有并且 [x..y] 是空集。集合构造器 [ ] 表示空集,[x] 表示仅含有一个元素x的集合。
集合构造器范例:
[red, green, MyColor]
[1, 5, 10..K mod 12, 23]
['A'..'Z', 'a'..'z', Chr(Digit + 48)]
有关集合的更多信息,见集合。