This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Operations  /
Union

  • Union[ , , ... ] gives a sorted list of all the distinct elements that appear in any of the .
  • Union[ list ] gives a sorted version of a list, in which all duplicated elements have been dropped.
  • If the are considered as sets, Union gives their union.
  • Union[ , , ... ] can be input in StandardForm and InputForm as ... . The character can be entered as un or \[Union].
  • The must have the same head, but it need not be List.
  • Union[ , ... , SameTest-> test ] applies test to each pair of elements in the to determine whether they should be considered the same.
  • See the Mathematica book: Section 1.8.7Section 1.8.8.
  • See also: Join, Intersection, Complement, Split.

    Further Examples

    Here is the set-theoretic union of a list of elements.

    In[1]:=

    Out[1]=

    This condenses the list and sorts it.

    In[2]:=

    Out[2]=