gathers the elements of list into sublists of identical elements.


applies test to pairs of elements to determine if they should be considered identical.


  • The default function used to test whether elements are identical is SameQ.
  • Gather[{e1,e2,},p] will gather together elements for which p[ei,ej] returns True.


open allclose all

Basic Examples  (2)

Gather elements into sublists of identical elements:

Gather elements that have identical first parts:

Applications  (3)

Gather elements that have equal integer parts:

Gather integers that have identical remainders:

Gather polynomials that have identical remainders:

Properties & Relations  (2)

DeleteDuplicates[list] is equivalent to Gather[list][[All,1]]:

For a large list, DeleteDuplicates is much faster:

GatherBy[list,f] is equivalent to Gather[list,(f[#1]===f[#2])&]:

Gather the rows by Norm and display with the common norm of each group:

Compare to the result of Gather:

Possible Issues  (1)

When the test cannot be identified as an equality comparison, Gather may be much slower:

The results are identical:

Wolfram Research (2008), Gather, Wolfram Language function,


Wolfram Research (2008), Gather, Wolfram Language function,


@misc{reference.wolfram_2021_gather, author="Wolfram Research", title="{Gather}", year="2008", howpublished="\url{}", note=[Accessed: 04-August-2021 ]}


@online{reference.wolfram_2021_gather, organization={Wolfram Research}, title={Gather}, year={2008}, url={}, note=[Accessed: 04-August-2021 ]}


Wolfram Language. 2008. "Gather." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2008). Gather. Wolfram Language & System Documentation Center. Retrieved from