nubBy

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.
A version of nub with a custom comparison predicate. Note: This function makes use of sortByUniq using the intro sort algorithm.
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}
The nubByMut function takes in an in-place sort algorithm and uses it to do a de-deduplicated sort. It then uses this to remove duplicate elements from the input. Note: Since this algorithm needs the original input and so copies before sorting in-place. As such, it is safe to use on immutable inputs.
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