1
Fork 0

#9 Polishing shuffle

This commit is contained in:
Tibo De Peuter 2022-11-14 18:25:38 +01:00
parent 33c9a877d2
commit fd92ba9d8f

View file

@ -1,12 +1,23 @@
module Shuffle (
shuffle
module Shuffle
( shuffle
) where
import Data.List
import System.Random
----------------------------------------------------------------------
-- Shuffle a list so that the elements of the list are randomly --
-- perumated. --
----------------------------------------------------------------------
----------------------------- Constants ------------------------------
-- The seed used to generate random numbers.
seed :: Int
seed = 20
----------------------------------------------------------------------
-- Shuffle a list of values.
shuffle :: [a] -> [a]
shuffle l = map (l !!) $ generateIndices $ length l
@ -19,6 +30,5 @@ generateIndices size = take size uniqueList
uniqueList = nub randomList
-- Generate a random generator
-- TODO Écht random maken?
randomGen :: StdGen
randomGen = mkStdGen seed