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

Description

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

Synopsis

Documentation

randomPermute :: RandomGen g => [a] -> g -> ([a], g) Source #

Generate a random permutation of the elements of a list.

Examples

>>> fst $ randomPermute [1..10] $ mkStdGen 111
[8,4,7,9,3,5,10,2,1,6]
>>> take 5 $ unfoldr (Just . randomPermute ['a'..'d']) $ mkStdGen 111
["cbad","abdc","abdc","acdb","cdba"]
>>> fst . randomPermute "abcdef" <$> newStdGen
"dcaebf"