Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2021 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Functions to remove duplicates from a list.
Performance
To check the performance there was done a bunch of benchmarks.
Benchmarks were made on lists of Int
s and Text
s.
There were two types of list to use:
- Lists which consist of many different elements
- Lists which consist of many same elements
Here are some recommendations for usage of particular functions based on benchmarking results.
hashNub
is faster thanordNub
when there're not so many different values in the list.hashNub
is the fastest withText
.intNub
is faster when you work with lists ofInt
s.intNubOn
is fast with the lists of type that can have fixed number representations.sortNub
has better performance thanordNub
but should be used when sorting is also needed.unstableNub
has better performance thanhashNub
but doesn't save the original order.
Documentation
ordNubOn :: forall b a. Ord b => (a -> b) -> [a] -> [a] Source #
Similar to ordNub
but performs nub through the mapped list on the given
function.
>>>
ordNubOn (`div` 10) [3, 3, 3, 13, 2, 22, -1, 1, 66]
[3,13,22,-1,66]
Since: 1.0.0.0