Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > List Manipulation > Rearranging & Restructuring Lists >
Mathematica > Data Manipulation > Handling Arrays of Data > Rearranging & Restructuring Lists >

Complement

Complement[eall, e1, e2, ...]
gives the elements in eall which are not in any of the ei.
  • The list returned by Complement is sorted into standard order.
  • Complement[eall, e1, ..., SameTest->test] applies test to each pair of elements in eall and the ei to determine whether they should be considered the same.
Find which elements in the first list are not in any of the subsequent lists:
Find which elements in the first list are not in any of the subsequent lists:
In[1]:=
Click for copyable input
Out[1]=
Complement works with any head, not just List:
Find divisors of 20 that are not also divisors of 12:
Find which triples of digits do not occur in the binary decomposition of 12345:
Find which options to Plot are not also options to Graphics:
Find which length-5 sequences never occur after 2 steps in any elementary cellular automaton:
New in 1 | Last modified in 3
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team