({{, (RefLink[Complement, paclet:ref/Complement])[(Subscript[e, all]),(Subscript[e, 1]),(Subscript[e, 2]),…]
gives the elements in (Subscript[e, all]) that are not in any of the (Subscript[e, i]). }})

OpenersNotesSection(Spacer1)Details and Options

The list returned by (RefLink[Complement, paclet:ref/Complement]) is sorted into standard order.

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Find which elements in the first list are not in any of the subsequent lists:

Complement[{a,b,c,d,e},{a,c},{d}]

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (1)

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

Complement[f[a,b,c,d],f[c,a],f[b,b,a]]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)SameTest  (3)

Use equivalence classes based on absolute value:

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

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

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

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

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

OpenersExampleSection3(Spacer1)Applications  (4)

Find divisors of 20 that are not also divisors of 12:

Complement[Divisors[20],Divisors[12]]

Find which triples of digits do not occur in the binary decomposition of 12345:

Complement[Tuples[{0,1},3],Partition[IntegerDigits[12345,2],3,1]]

Find which options to (RefLink[Plot, paclet:ref/Plot]) are not also options to (RefLink[Graphics, paclet:ref/Graphics]):

Complement[First/@Options[Plot],First/@Options[Graphics]]

Find which length-5 sequences never occur after 2 steps in any elementary cellular automaton:

Complement[Tuples[{0,1},5],Table[Last[CellularAutomaton[i,{{1},0},{2,All}]],{i,0,255}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Intersection, paclet:ref/Intersection])  ▪  (RefLink[Union, paclet:ref/Union])  ▪  (RefLink[Take, paclet:ref/Take])  ▪  (RefLink[Select, paclet:ref/Select])  ▪  (RefLink[DisjointQ, paclet:ref/DisjointQ])  ▪  (RefLink[SubsetQ, paclet:ref/SubsetQ])  ▪  (RefLink[ContainsOnly, paclet:ref/ContainsOnly])  ▪  (RefLink[ContainsAll, paclet:ref/ContainsAll])}})}})

({{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=Complement]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})