x in Sor
x (- Stests if a value x belongs to a set S.
The following are several ways to create sets.
Finite sets can be created by listing all the members
colors = {"red", "orange", "yellow", "green", "blue", "purple"} faces = {1, 2, 3, 4, 5, 6}
Intervals of real numbers are created by using the to operator
I1 = -1 to 1; // closed interval [-1, 1] I2 = -1+ to 1-; // open interval (-1, 1) I3 = (-1 to 1-); // interval [-1, 1) I4 = (-1+ to inf); // (1, infinity)
Any function can be used as a set. If the logical value of f(x) is true, then x is considered a member of set f. For example
S = x -> (x <= 0 || x >= 1);
There are many built-in sets (or built-in functions), for example, _R is the set of all real numbers, _R2 is the set of all vectors of real numbers of length 2, etc.
Union operator \/, intersection operator /\, and set difference operator \ can be used to create new sets from existing ones.
A class is considered the set of all its members, and hence naturally can be be used as a set.