random-fu-0.3.0.1: Random number generation

Safe Haskell | None
Language | Haskell2010

Data.Random.List

Synopsis

- randomElement :: [a] -> RVar a
- randomElementT :: forall a (m :: Type -> Type). [a] -> RVarT m a
- shuffle :: [a] -> RVar [a]
- shuffleT :: forall a (m :: Type -> Type). [a] -> RVarT m [a]
- shuffleN :: Int -> [a] -> RVar [a]
- shuffleNT :: forall a (m :: Type -> Type). Int -> [a] -> RVarT m [a]
- shuffleNofM :: Int -> Int -> [a] -> RVar [a]
- shuffleNofMT :: forall a (m :: Type -> Type). Int -> Int -> [a] -> RVarT m [a]

# Documentation

randomElement :: [a] -> RVar a Source #

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."

randomElementT :: forall a (m :: Type -> Type). [a] -> RVarT m a Source #

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.

shuffleT :: forall a (m :: Type -> Type). [a] -> RVarT m [a] Source #

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

A random variable that shuffles a list of a known length (or a list prefix of the specified 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.

shuffleNT :: forall a (m :: Type -> Type). Int -> [a] -> RVarT m [a] Source #

shuffleNofM :: Int -> Int -> [a] -> RVar [a] Source #

A random variable that selects N arbitrary elements of a list of known length M.

shuffleNofMT :: forall a (m :: Type -> Type). Int -> Int -> [a] -> RVarT m [a] Source #