Red has some basic operations to use so that it can work with series as sets. For example, say we have two sets, s1 and s2, containing s1: [7 13 42 108] and s2: [2 7 14 42 109] (the code can be found in Chapter05/sets.red):
- union s1 s2 returns [7 13 42 108 2 14 109]: the series are joined together, and duplicates are eliminated
- intersect s1 s2 returns [7 42]: only the common elements are retained
- difference s1 s2 returns [13 108 2 14 109]: only the elements that are not common to both are retained
- exclude s1 s2 returns [13 108]: all elements from the second set are removed from the first set