- uniqSort :: Ord a => [a] -> [a]
- aggregate :: Ord a => [a] -> [[a]]
- aggregateBy :: (a -> a -> Ordering) -> [a] -> [[a]]
- aggregateAL :: Ord a => [(a, b)] -> [(a, [b])]
- nat0 :: Num n => [n]
- nat1 :: Num n => [n]
- average :: Fractional a => [a] -> a
- averageI :: (Integral i, Fractional a) => [i] -> a
- relFreq :: (Integral i, Fractional f) => [i] -> [f]
- relFreqAL :: (Integral i, Fractional f) => [(a, i)] -> [(a, f)]
- majority :: Ord a => [a] -> a
- oddIx :: [b] -> [b]
- evenIx :: [b] -> [b]

# Sorting-like

uniqSort :: Ord a => [a] -> [a]Source

Sort a list and leave out duplicates. Like `nub . sort`

but faster.

aggregateBy :: (a -> a -> Ordering) -> [a] -> [[a]]Source

Sort, then group

aggregateAL :: Ord a => [(a, b)] -> [(a, [b])]Source

Aggregate an association list, such that keys become unique.

# Numeric lists

average :: Fractional a => [a] -> aSource

Calculate the arithmetic mean. May not be numerically robust for some types and lists. Double and Rational should be fine most of the time.

averageI :: (Integral i, Fractional a) => [i] -> aSource

Shortcut for `average . map fromIntegral`

. Check numerical robustness, see `average`

above.

relFreq :: (Integral i, Fractional f) => [i] -> [f]Source

Turn a list of integer frequencies into relative frequencies that sum up to 1. Frequencies should be nonnegative.

relFreqAL :: (Integral i, Fractional f) => [(a, i)] -> [(a, f)]Source

Turn an association list of integer frequencies into on of relative frequencies that sum up to 1. Frequencies should be nonnegative.