lundi 25 juin 2018

How to generate random Int in Haskell?

i'm trying to generate a random index (Int), with this code: randomRIO (0, 2 :: Int). But its generate a IO Int, so i cant do something like this: [1,2,3] !! randomIndex. What does it have to be done to convert the IO Int to Int? Thanks.




Aucun commentaire:

Enregistrer un commentaire