nubBy -package:vector-algorithms

The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded (==) function.

Examples

>>> nubBy (\x y -> mod x 3 == mod y 3) [1,2,4,5,6]
[1,2,6]
>>> nubBy (/=) [2, 7, 1, 8, 2, 8, 1, 8, 2, 8]
[2,2,2]
>>> nubBy (>) [1, 2, 3, 2, 1, 5, 4, 5, 3, 2]
[1,2,3,5,5]
The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded == function.
The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded == function.
>>> nubBy (\x y -> mod x 3 == mod y 3) [1,2,4,5,6]
[1,2,6]
Generic version of nub
Drop repeated elements anywhere in the stream. Caution: not scalable for infinite streams See also: nubWindowBy Unimplemented
The nubBy function is the greedy algorithm that returns a sublist of its input such that:
isSortedBy pred (nubBy pred xs) == True
This is true for all lists, not just ordered lists, and all binary predicates, not just total orders. On infinite lists, this statement is true in a certain mathematical sense, but not a computational one.
Overloaded version of nub. Consider using nubOrdBy instead.
Delete all but the first copy of each element, with the given relation.
O(n^2). Behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded == function.
>>> nubBy (\x y -> mod x 3 == mod y 3) $ slist [1,2,4,5,6]
Slist {sList = [1,2,6], sSize = Size 3}
Like ordNub and nubBy. Selects a key for each element and takes the nub based on that key.
same behavior as nubBy, but requires Ord and is O(n log n) https://github.com/nh2/haskell-ordnub
Modify a query to only return rows where the supplied key function returns a unique value. This corresponds to the Postgres DISTINCT ON support.