ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.P24

Description

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P24.

Synopsis

Documentation

randomDraw :: RandomGen g => Int -> Int -> g -> ([Int], g) Source #

Draw \(n\) different random numbers from the set \( \{ k \,|\, 1 \leq k \leq m \} \).

Examples

>>> fst $ randomDraw 6 49 $ mkStdGen 111
[40,13,25,27,26,6]
>>> take 5 $ unfoldr (Just . randomDraw 3 100) $ mkStdGen 111
[[11,19,76],[63,49,10],[75,42,12],[20,48,78],[40,94,86]]
>>> fst . randomDraw 6 49 <$> newStdGen
[17,7,1,18,13,3]