Enum.uniq_by
You're seeing just the function
uniq_by
, go back to Enum module for more information.
Specs
Enumerates the enumerable
, by removing the elements for which
function fun
returned duplicate elements.
The function fun
maps every element to a term. Two elements are
considered duplicates if the return value of fun
is equal for
both of them.
The first occurrence of each element is kept.
Example
iex> Enum.uniq_by([{1, :x}, {2, :y}, {1, :z}], fn {x, _} -> x end)
[{1, :x}, {2, :y}]
iex> Enum.uniq_by([a: {:tea, 2}, b: {:tea, 2}, c: {:coffee, 1}], fn {_, y} -> y end)
[a: {:tea, 2}, c: {:coffee, 1}]