random-fu- Random number generation




randomElement :: [a] -> RVar aSource

A random variable returning an arbitrary element of the given list. Every element has equal probability of being chosen. Because it is a pure RVar it has no memory - that is, it "draws with replacement."

shuffle :: [a] -> RVar [a]Source

A random variable that returns the given list in an arbitrary shuffled order. Every ordering of the list has equal probability.

shuffleN :: Int -> [a] -> RVar [a]Source

A random variable that shuffles a list of a known length. Useful for shuffling large lists when the length is known in advance. Avoids needing to traverse the list to discover its length. Each ordering has equal probability.

Throws an error the list is not exactly as long as claimed.