List Operations

Use our free tool for set operations (union, intersection, and difference) on item lists. Enter your two sets into List A and List B. Choose the operation and view the result in the Output.

List A

List B

Actions

Actions allow you to perform various operations on lists A and B, with results displayed in the Output section

List Operations (A and B)

Placeholder Replacement

Load or edit a template from the list

Output

Settings

List Toolbar

Sorting:


Normalize:

Output

Separator





Text qualifier



Other
Normalization

Exploring Set Operations


Set operations, commonly used in mathematics, involve functions that take two sets or unordered lists and produce a third list based on predefined operations. Unlike standard mathematical operations such as addition and subtraction, set operations manipulate the entire list as a cohesive unit. Continue reading for an in-depth look at each operation.

Union


Union of Two Sets

The union (join, sum, combination, merge) of two sets, also known as the union operation, involves combining the elements of two sets into one, excluding any duplicates. It's akin to merging two collections of distinct items.

For instance, if Set A contains apples, oranges, and bananas, and Set B contains oranges, grapes, and kiwis, the union of Set A and Set B includes all these fruits: apples, oranges, bananas, grapes, and kiwis.

Example: {1, 2, 3} ∪ {3, 4, 5} = {1, 2, 3, 4, 5}

Intersection


Intersection of Two Sets

The intersection (commonality, meet, joint, overlap) of two sets, also referred to as the intersection operation, consists of the elements that are common to both sets. It's like finding the shared elements between two distinct groups.

For example, if Set X represents students who play soccer (Alex, Sam, Emily) and Set Y represents students who play basketball (Sam, Emily, Chris), the intersection of Sets X and Y includes only the students who play both soccer and basketball: Sam and Emily.

Example: {1, 2, 3} ∩ {3, 4, 5} = {3}.

Difference A-B, B-A


Difference of Two Sets

The difference of two sets, known as the set difference operation, represents the elements that belong to one set but not the other. It's akin to subtracting one collection of items from another. This operation can be performed in both directions: A-B and B-A. When we compute A-B, we extract the elements from set A that are not present in set B. Conversely, when we compute B-A, we extract the elements from set B that are not present in set A.

For instance, if Set P represents all students enrolled in science courses (John, Emily, Sarah, Mike) and Set Q represents students enrolled in math courses (Emily, Sarah), the difference of Sets P and Q includes only the students enrolled in science but not in math: John and Mike.

Examples:

  • A - B: {1, 2, 3} − {3, 4, 5} = {1, 2}.
  • B - A: {1, 2, 3} − {3, 4, 5} = {4, 5}.

Symmetric Difference


Symmetric Difference of Two Sets

The symmetric difference of two sets, also known as the symmetric set difference operation, comprises the elements that are unique to each set, excluding those shared between them. It's like combining the differences of both sets.

For example, if Set M represents people who like apples, oranges, and bananas, and Set N represents people who like oranges, bananas, and grapes, the symmetric difference includes apples and grapes, which are unique preferences within each set.

Example: {1, 2, 3} Δ {3, 4, 5} = {1, 2, 4, 5}.

Combine A & B


Combining sets A and B, commonly known as the cartesian product (permutations), involves pairing each element from set A with every element from set B. This process generates all possible combinations of elements from both sets.

For instance, if Set A contains elements (red, blue) and Set B contains elements (circle, square), the Cartesian product of Sets A and B results in pairs like (red circle, red square, blue circle, blue, square).

Example: {a, b} × {1, 2, 3} = {(a,1), (a,2), (a,3), (b,1), (b,2), (b,3)}.