The union, intersect, minus, and subset routines are used for the set union, intersection, difference, and subset operations. The union and intersect routines are infix, associative, commutative, n-ary operators. The minus and subset routines are binary infix operators.

If an argument is an expression, it must be possible for that object to evaluate to a set. If any argument cannot be assigned a set, an error is returned. For example, the union of 1&comma;2&comma;3 and 4 returns an error, while the union of 1&comma;2&comma;3 and S returns unevaluated.

•

You can enter these commands using either the 1-D or 2-D calling sequences. For example, {a,b} union {b,c} is equivalent to a&comma;b∪b&comma;c.

•

When using the union(s1,s2) calling sequence in 1-D Math notation, you must enclose union in backquotes since it is a keyword: `union`(s1,s2). In 2-D Math notation, backquotes are not necessary.

Note: The set operations are based on address tests. If two set elements appear to be the same but have different addresses, the test fails. This is illustrated by the final example.

Thread Safety

•

The set operators are thread safe as of Maple 15.

Examples

>

a&comma;b&cup;b&comma;c

a&comma;b&comma;c

(1)

>

a&comma;b&cap;b&comma;c

b

(2)

>

a&comma;b&setmn;b&comma;c

a

(3)

>

a&cup;b&cup;a

a&cup;b

(4)

>

3&comma;4&cup;a&cup;3&comma;7

a&cup;3&comma;4&comma;7

(5)

>

`union`&ApplyFunction;3&comma;4&comma;a&comma;3&comma;7

a&cup;3&comma;4&comma;7

(6)

>

a&cap;b&cap;a

a&cap;b

(7)

>

3&comma;4&cap;a&cap;3&comma;7

a&cap;3

(8)

>

`intersect`&ApplyFunction;3&comma;4&comma;a&comma;3&comma;7

a&cap;3

(9)

minus and subset are binary operators.

>

a&setmn;b&setmn;a

a&setmn;b&setmn;a

(10)

>

a&setmn;b&setmn;a

(11)

>

3&comma;4&setmn;3&comma;7

4

(12)

>

a&comma;b&sube;a&comma;c&comma;b&comma;d

true

(13)

>

a&comma;b&sube;a&comma;c&comma;d&comma;e

false

(14)

>

a&sube;b&cup;c

a&sube;b&cup;c

(15)

The order of precedence for set operators is: intersect, union and minus, then subset.

>

1&comma;2&sube;1&comma;3&comma;7&cup;2&comma;4

true

(16)

>

1&comma;2&cup;1&comma;2&comma;3&cap;3&comma;4&comma;5

1&comma;2&comma;3

(17)

>

1&comma;2&cup;1&comma;2&comma;3&cap;3&comma;4&comma;5

3

(18)

The set operations are based on address test. If two set elements appear to be the same but have different addresses, the test fails.