Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

Lists as Sets

The Wolfram Language usually keeps the elements of a list in exactly the order you originally entered them. If you want to treat a Wolfram Language list like a mathematical set, however, you may want to ignore the order of elements in the list.

Union[list1,list2,]give a list of the distinct elements in the listi
Intersection[list1,list2,]give a list of the elements that are common to all the listi
Complement[universal,list1,]give a list of the elements that are in universal, but not in any of the listi
Subsets[list]give a list of all subsets of the elements in list
DeleteDuplicates[list]delete all duplicates from list

Set theoretical functions.

Union gives the elements that occur in any of the lists.
Click for copyable input
Intersection gives only elements that occur in all the lists.
Click for copyable input
Complement gives elements that occur in the first list, but not in any of the others.
Click for copyable input
This gives all the subsets of the list.
Click for copyable input
DeleteDuplicates deletes all duplicate elements from the list.
Click for copyable input