toolshed-0.17.0.2: Ill-defined library.

Safe HaskellSafe
LanguageHaskell2010

ToolShed.System.Random

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Utilities related to random-numbers.

Synopsis

Functions

randomGens :: RandomGen randomGen => randomGen -> [randomGen] Source #

Constructs an infinite list of independent random-generators.

shuffle :: RandomGen randomGen => randomGen -> [a] -> [a] Source #

  • Shuffles the specified finite list, using the Fisher-Yates algorithm; https://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
  • The resulting list has the same length and constituents as the original; only the order has changed.
  • The input list is traversed, but the items aren't evaluated.

generateSelection :: RandomGen randomGen => randomGen -> [a] -> Maybe [a] Source #

  • Generate an infinite list of items, each independently randomly selected from the specified finite list.
  • CAVEAT: because the selections are made non-destructively, duplicates may be returned; cf. shuffle.

generateSelectionFromBounded :: (RandomGen randomGen, Bounded a, Random a) => randomGen -> [a] Source #

  • Generate an infinite list of data, each independently selected random instances of the specified bounded type.
  • E.g. (generateSelectionFromBounded fmap System.Random.getStdGen) :: IO [Bool] .

select :: (Foldable foldable, RandomGen randomGen) => randomGen -> foldable a -> Maybe a Source #

Return a randomly selected element from those provided.