DeleteDuplicatesBy

DeleteDuplicatesBy[{e1,e2,},f]

deletes those ei that yield duplicates in the list {f[e1],f[e2],}.

DeleteDuplicatesBy[f]

represents an operator form of DeleteDuplicatesBy that can be applied to an expression.

Details

  • DeleteDuplicatesBy[list,f] deletes all but the first ei to produce each distinct value of f[ei].
  • DeleteDuplicatesBy[<|key1val1,key2val2,|>,f] deletes values of f[vali] that duplicate earlier elements, ignoring the keyi.
  • DeleteDuplicatesBy never reorders elements, but only removes them.
  • DeleteDuplicatesBy[f][expr] is equivalent to DeleteDuplicatesBy[expr,f].

Examples

Basic Examples  (2)

Delete pairs with a duplicate last element:

Delete values from an association that have the same magnitude:

Use the operator form of DeleteDuplicatesBy:

Wolfram Research (2014), DeleteDuplicatesBy, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html.

Text

Wolfram Research (2014), DeleteDuplicatesBy, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html.

CMS

Wolfram Language. 2014. "DeleteDuplicatesBy." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html.

APA

Wolfram Language. (2014). DeleteDuplicatesBy. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html

BibTeX

@misc{reference.wolfram_2024_deleteduplicatesby, author="Wolfram Research", title="{DeleteDuplicatesBy}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html}", note=[Accessed: 14-June-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_deleteduplicatesby, organization={Wolfram Research}, title={DeleteDuplicatesBy}, year={2014}, url={https://reference.wolfram.com/language/ref/DeleteDuplicatesBy.html}, note=[Accessed: 14-June-2024 ]}