({{, (RefLink[Intersection, paclet:ref/Intersection])[(Subscript[list, 1]),(Subscript[list, 2]),…]
gives a sorted list of the elements common to all the (Subscript[list, i]). }})

OpenersNotesSection(Spacer1)Details and Options

If the (Subscript[list, i]) are considered as sets, (RefLink[Intersection, paclet:ref/Intersection]) gives their intersection.

(RefLink[Intersection, paclet:ref/Intersection])[(Subscript[list, 1]),(Subscript[list, 2]),…] can be input in (RefLink[StandardForm, paclet:ref/StandardForm]) and (RefLink[InputForm, paclet:ref/InputForm]) as (Subscript[list, 1])⋂(Subscript[list, 2])⋂…. The character ⋂ can be entered as (Key0[esc]) inter (Key0[esc]) or (RefLink[\[Intersection], paclet:ref/character/Intersection]).

The (Subscript[list, i]) must have the same head, but it need not be (RefLink[List, paclet:ref/List]).

(RefLink[Intersection, paclet:ref/Intersection])[(Subscript[list, 1]),…,(RefLink[SameTest, paclet:ref/SameTest])->test] applies test to each pair of elements in the (Subscript[list, i]) to determine whether they should be considered the same.

(RefLink[Intersection, paclet:ref/Intersection])[a,b] can be entered in (RefLink[StandardForm, paclet:ref/StandardForm]) and (RefLink[InputForm, paclet:ref/InputForm]) as a⋂b or a∖[Intersection]b.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Find elements common to all the lists given:

Intersection[{1,1,2,3},{3,1,4},{4,1,3,3}]

Enter using (Key0[esc]) inter (Key0[esc]):

{a,b,c}⋂{b,c,d}

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (1)

(RefLink[Intersection, paclet:ref/Intersection]) works with any head, not just (RefLink[List, paclet:ref/List]):

Intersection[f[a,b],f[c,a],f[b,b,a]]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)SameTest  (3)

Use equivalence classes based on absolute value:

Intersection[{2,-2,1,3,1},{2,1,-2,-1},SameTest->(Abs[#1]==Abs[#2]&)]

Use equivalence classes based on (RefLink[Floor, paclet:ref/Floor]):

Intersection[{1.1,3.4,.5,7.6,7.1,1.9},{1.2,3.3,7.7,1.3},SameTest->(Floor[#1]==Floor[#2]&)]

Use (RefLink[Total, paclet:ref/Total]) of list elements:

Intersection[{{1,2},{3},{4,5,6},{9,6}}, {{2,1},{8,4,3}},SameTest->(Total[#1]==Total[#2]&)]

OpenersExampleSection3(Spacer1)Applications  (1)

Find divisors common to 45 and 78:

Intersection[Divisors[45],Divisors[78]]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

If there is no intersection, the result is {}:

Intersection[{a,b,c},{d,e,f}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Union, paclet:ref/Union])  ▪  (RefLink[Complement, paclet:ref/Complement])  ▪  (RefLink[And, paclet:ref/And])  ▪  (RefLink[BitAnd, paclet:ref/BitAnd])  ▪  (RefLink[SequenceAlignment, paclet:ref/SequenceAlignment])  ▪  (RefLink[IntersectingQ, paclet:ref/IntersectingQ])  ▪  (RefLink[DisjointQ, paclet:ref/DisjointQ])  ▪  (RefLink[ContainsAny, paclet:ref/ContainsAny])  ▪  (RefLink[ContainsNone, paclet:ref/ContainsNone])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Lists as Sets, paclet:tutorial/ListsAsSets])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Operations on Sets, paclet:guide/OperationsOnSets])}, {▪(RefLinkPlain[Math & Counting Operations on Lists, paclet:guide/MathematicalAndCountingOperationsOnLists])}, {▪(RefLinkPlain[Rearranging & Restructuring Lists, paclet:guide/RearrangingAndRestructuringLists])}, {▪(RefLinkPlain[Discrete Mathematics, paclet:guide/DiscreteMathematics])}, {▪(RefLinkPlain[Discrete & Integer Data, paclet:guide/DiscreteAndIntegerData])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/30-rearranging-lists.html])(WebLink[: Rearranging Lists, https://www.wolfram.com/language/elementary-introduction/30-rearranging-lists.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=Intersection]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})