6.10.7 Set Operations

GPC supports Standard Pascal set operations. In addition it supports
the Extended Pascal set operation symmetric difference
(set1 >< set2) operation whose result consists of those
elements which are in exactly one of the operannds.

It also has a function that counts the elements in the set:
a := Card (set1).

In the following description, S1 and S2 are variables of set type,
s is of the base type of the set.

S1 := S2

Assign a set to a set variable.

S1 + S2

Union of sets.

S1 - S2

Difference between two sets.

S1 * S2

Intersection of two sets.

S1 >< S2

Symmetric difference

S1 = S2

Comparison between two sets. Returns boolean result. True if
S1 has the same elements as S2.

S1 <> S2

Comparison between two sets. Returns boolean result. True if
S1 does not have the same elements as S2.

S1 < S2

S2 > S1

Comparison between two sets. Returns boolean result. True if
S1 is a strict subset of S2.

S1 <= S2

S2 >= S1

Comparison between two sets. Returns boolean result. True if
S1 is a subset of (or equal to) S2.

s in S1

Set membership test between an element s and a set. Returns
boolean result. True if s is an element of S1.

The following example demonstrates some set operations. The results
of the operations are given in the comments.