LambdaHack- A game engine library for roguelike dungeon crawlers

Safe HaskellNone




A list of items with relative frequencies of appearance.


The Frequency type

data Frequency a Source

The frequency distribution type. Not normalized (operations may or may not group the same elements and sum their frequencies).

The Eq instance compares raw representations, not relative, normalized frequencies, so operations don't need to preserve the expected equalities, unless they do some kind of normalization (see Dice).


uniformFreq :: Text -> [a] -> Frequency a Source

Uniform discrete frequency distribution.

toFreq :: Text -> [(Int, a)] -> Frequency a Source

Takes a name and a list of frequencies and items into the frequency distribution.


scaleFreq :: Show a => Int -> Frequency a -> Frequency a Source

Scale frequecy distribution, multiplying it by a positive integer constant.

renameFreq :: Text -> Frequency a -> Frequency a Source

Change the description of the frequency.

setFreq :: Eq a => Frequency a -> a -> Int -> Frequency a Source

Set frequency of an element.


nullFreq :: Frequency a -> Bool Source

Test if the frequency distribution is empty.

runFrequency :: Frequency a -> [(Int, a)] Source

give acces to raw frequency values

nameFrequency :: Frequency a -> Text Source

short description for debug, etc.; keep it lazy, because it's rarely used

maxFreq :: (Show a, Ord a) => Frequency a -> a Source

minFreq :: (Show a, Ord a) => Frequency a -> a Source