Intersect
Intersect[ list1, list2, ...]
Intersect[ list1, list2, ...] returns the list of all elements that occur in all lists list1, list2, ..... The resulting list contains duplicates only if all the lists contain duplicates.
| Example | in | out |
|---|---|---|
The intersection of {a,b,g} and {a,b,c,d,e,a} |
Intersect[ {a,b,g}, {a,b,c,d,e,a} ] |
{a,b} |
The intersection of {a,b,g,a} and {a,c,a}. |
Intersect[ {a,b,g,a}, {a,c,a} ] |
{a, a} |
The intersection of {a,b,g,a}, {a,b,c,d,e,a} and { g,d,f,a}. |
Intersect[ {a,b,g,a}, {a,b,c,d,e,a}, { g,d,f,a} ] |
{a} |
The intersection of x and y, where x is defined as {a,b,c} and y is defined as {b,c,d} in the script. |
Intersect[x, y] |
{b,c} |