Enum

dedup_by/2

dedup_by(enumerable, fun)

Discards all those adjacent elements in enumerable which are duplicated in terms of the output of the fun function, collapsing them in a single element.