hinduce-missingh-0.0.0.0: Utility functions

Data.List.HIUtils

Contents

Synopsis

Sorting-like

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

Sort a list and leave out duplicates. Like nub . sort but faster.

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

Sort, then group

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

nat0 :: Num n => [n]Source

Infinite integer sequence of the natural numbers, starting at 0

nat1 :: Num n => [n]Source

Infinite integer sequence of the natural numbers, starting at 1

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.

Lists with Eq

majority :: Ord a => [a] -> aSource

Find the most frequently occurring element. TODO: rewrite for Eq

Polymorphic list operations

oddIx :: [b] -> [b]Source

evenIx :: [b] -> [b]Source