Safe Haskell | None |
---|---|
Language | GHC2021 |
Freckle.App.Random
Synopsis
- smallRandomSubsetOfLargeIntegerRange :: (MonadRandom m, Random i, Integral i) => Natural -> Range i -> m (Set i)
- data Range i
- = RangeEmpty
- | RangeNonEmpty (NonEmptyRange i)
- data NonEmptyRange i = NonEmptyRange {
- inclusiveMinBound :: i
- offset :: Natural
- inclusiveRange :: Integral i => i -> i -> Range i
Documentation
smallRandomSubsetOfLargeIntegerRange Source #
Arguments
:: (MonadRandom m, Random i, Integral i) | |
=> Natural | How many items are wanted |
-> Range i | |
-> m (Set i) |
Select a fixed number of items uniformly at random from a contiguous range of integers
This process accommodates selecting from a large range, but only has reasonable performance when the number of items being selected is small (it is quadratic in the number of items).
If the requested size is greater than or equal to the range, the entire range is returned.
e.g. smallRandomSubsetOfLargeIntegerRange 10 (inclusiveRange 30 70)
may produce something like fromList [32,34,45,54,56,58,62,63,64,65]
.
A possibly-empty contiguous range of integers
Constructors
RangeEmpty | |
RangeNonEmpty (NonEmptyRange i) |
data NonEmptyRange i Source #
A nonempty contiguous range of integers
Constructors
NonEmptyRange | |
Fields
|