Complement
Complement[eall,e1,e2,…]
gives the elements in eall that are not in any of the ei.
Details and Options
- 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.
Examples
open allclose allGeneralizations & Extensions (1)
Complement works with any head, not just List:
Options (3)
Applications (4)
Properties & Relations (1)
The result of Complement[list1,list2] is sorted and does not contain repeated elements:
This returns the same elements, but preserving the original order and multiplicity in list1:
Use DeleteDuplicates to preserve order but remove multiplicity:
Text
Wolfram Research (1988), Complement, Wolfram Language function, https://reference.wolfram.com/language/ref/Complement.html (updated 1996).
CMS
Wolfram Language. 1988. "Complement." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/Complement.html.
APA
Wolfram Language. (1988). Complement. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Complement.html