Declaration and Assignment

It is good practice to define a set type and then declare variables of that type e.g.

  TDigitSet = set of 0..9;
  TCapsSet = set of 'A' .. 'Z';
  TMonthSet = set of TMonth; //where TMonth has been declared as an enumerated type 
  UsedDigitSet : TDigitSet;
  ChosenCapsSet, VowelCapsSet, ConsonantCapsSet : TCapsSet;
  WetMonthSet : TMonthSet;

A set constructor is used to assign a value to a set variable. You write the constructor by enclosing a comma-separated list of the required set elements in square brackets e.g.

UsedDigitSet := [1, 4, 7];
ChosenCapsSet := ['C', 'A'];
WetMonthSet := [January, October];
Programming - a skill for life!

Declaration, assignment, operators and functions of sets