Vector.distinct
distincton
Group: Selections
Aliases: deduplicate
, unique
Documentation
Keeps only unique elements within the vector, removing any duplicates.
The returned unique elements are kept in the same order as they appeared in the input. Out of multiple equivalent (equal up to the on
projection) elements, always the one appearing first in the input is kept.
Arguments
on
: A projection from the element type to the value of that element which determines the uniqueness criteria.
Examples
Removing repeating entries.
[1, 3, 1, 2, 2, 1] . distinct == [1, 3, 2]
Keeping only pairs whose first elements are unique.
[Pair 1 "a", Pair 2 "b", Pair 1 "c"] . distinct (on = _.first) == [Pair 1 "a", Pair 2 "b"]