dimanche 10 janvier 2021

How to generate a list of random Num elements without IO in Haskell

I need to generate list of random elements without IO monad, is there a way to do it? I managed to do myself a random list generating function only with IO, here it is:

genRandList :: Random a => a -> a -> Int -> IO [a]
genRandList a b n = take n . randomRs (a, b) <$> newStdGen

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire