Scripting > Expressions > Operators > Categorical set logic
 
Categorical set logic
This section provides a summary of the set operations for categorical variables. Some of the examples show using the operators with category names and some with the numeric category values.
Union
The union (+) operator performs a union of two category lists. The response order from the category list on the left is maintained above the one on the right.
Examples
Result
{5,2,1,8,6} + {1,5,3,9,7}
{5,2,1,8,6,3,9,7}
{FOSSILS, BIRDS, WHALES} + {WHALES, BIRDS, FOSSILS}
{FOSSILS, BIRDS, WHALES}
{FOSSILS, BIRDS, WHALES} + {MINERALS, ECOLOGY, BIRDS, FOSSILS}
{FOSSILS, BIRDS, WHALES, MINERALS, ECOLOGY}
Subtract
The subtract (-) operator returns the categories that are in the category list on the left but not in the category list on the right. The category order from the category list on the left is maintained above the category list on the right.
Examples
Result
{5,2,1,8,6} - {1,5,3,9,7}
{2,8,6}
{FOSSILS, BIRDS, WHALES} - {WHALES, BIRDS, FOSSILS}
{ }
{FOSSILS, BIRDS, WHALES} - {MINERALS, ECOLOGY, BIRDS, FOSSILS}
{WHALES}
Intersection
The intersection (*) operator performs an intersection of the two category lists. The category order from the category list on the left is maintained above the one on the right.
Examples
Result
{5,2,1,8,6} * {1,5,3,9,7}
{5,1}
{FOSSILS, BIRDS, WHALES} * {WHALES, BIRDS, FOSSILS}
{FOSSILS, BIRDS, WHALES}
{FOSSILS, BIRDS, WHALES} * {MINERALS, ECOLOGY, BIRDS, FOSSILS}
{FOSSILS, BIRDS}
Difference
The difference (/) operator returns the categories that are in either category list, but not in both category lists. The category order from the list on the left is maintained above the one on the right.
Examples
Result
{5,2,1,8,6} / {1,5,3,9,7}
{2,8,6,3,9,7}
{FOSSILS, BIRDS, WHALES} / {WHALES, BIRDS, FOSSILS}
{ }
{FOSSILS, BIRDS, WHALES} / {MINERALS, ECOLOGY, BIRDS, FOSSILS}
{WHALES, MINERALS, ECOLOGY}
See
Operators