The Intersection, Union, and Difference of Simple Members

Example

Calculate the intersection, union and difference of elements in two sets.

Write the SPL script:


A

1

[1,4,6,2,3,9,7]

2

[3,7,2,1,9,5,8,7]

3

=A1^A2

4

=A1&A2

5

=A1\A2

6

=A2&A1

7

=A2\A1

A1 Set 1

A2 Set 2 

A3 The intersection of set 1 and set 2 is: [1,2,3,9,7]

A4 The union of set 1 and set 2 is: [1,4,6,2,3,9,7,5,8,7]

A5 The difference between set 1 and set 2 is: [4,6]

A6 The union of set 2 and set 1 is: [3,7,2,1,9,5,8,7,4,6]

A7 The difference between set 2 and set 1 is: [5,8,7]

It can be seen that the order does matter when calculating union and difference.