Defining set types and variables in Pascal
Set types in Pascal are defined as:
Type
set-identifier = set of base type;
Set variables in Pascal are defined as:
Var
Declare s1, s2, ... as set-identifier;
Or:
Declare s1, s2... as set of base type;
Example declarations of set types in Pascal:
Set Operators in Pascal
The table below enumerates set operators in Pascal:
The table below lists the supported operators in Free Pascal. Assume S1 and S2 are two sets of characters:
S1 := ['a', 'b', 'c'];
S2 := ['c', 'd', 'e'];
Example of Set Operators in Pascal
Below is an example illustrating set operators in Pascal:
When the above code is compiled and executed, it will yield the following result:
So, here are all the details about set types in Pascal. Additionally, you can refer to some previous articles on Mytour to explore keywords and basic syntax in Pascal. In the next article, Mytour will continue introducing you to classes in Pascal.