9.7.5 Set operators

The following operations on sets can be performed with operators: Union, dierence and intersection. The operators needed for this are listed in table (9.6).


Table 9.6: Set operators

OperatorAction


+ Union
- Dierence
* Intersection



The set type of the operands must be the same, or an error will be generated by the compiler.

The following are valid examples of set operations:

Type  
  Day = (mon,tue,wed,thu,fri,sat,sun);  
  Days = set of WeekDay;  
 
Var  
  W : Days;  
 
begin  
  W:=[mon,tue]+[wed,thu,fri]; // equals [mon,tue,wed,thu,fri]  
  W:=[mon,tue,wed]-[wed];     // equals [mon,tue]  
  W:=[mon,tue,wed]*[wed,thu,fri]; // equals [wed]