Set

The expression
    x in S
or
    x (- S
tests if a value x belongs to a set S.

The following are several ways to create sets.

  1. Finite set

    Finite sets can be created by listing all the members

    colors = {"red", "orange", "yellow", "green", "blue", "purple"}
    faces = {1, 2, 3, 4, 5, 6}
    
  2. Interval

    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)
    

  3. Sets Defined by Functions

    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.

  4. Sets created by set operations

    Union operator \/, intersection operator /\, and set difference operator \ can be used to create new sets from existing ones.

  5. Class as set

    A class is considered the set of all its members, and hence naturally can be be used as a set.



oz 2009-12-22