Created
May 21, 2017 21:50
-
-
Save tan-yuki/6837e9d595b66fe166e08affac09a994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Random | |
dice :: StdGen -> Int | |
dice gen = num | |
where (num, _) = diceWithRandomGen gen | |
diceWithRandomGen :: StdGen -> (Int, StdGen) | |
diceWithRandomGen = randomR (1, 6) | |
threeTimesDiceRoll :: StdGen -> (Int, Int, Int) | |
threeTimesDiceRoll gen = (first, second, third) | |
where (first, firstGen) = diceWithRandomGen gen | |
(second, secondGen) = diceWithRandomGen firstGen | |
(third, _) = diceWithRandomGen secondGen | |
main :: IO () | |
main = do | |
gen <- getStdGen | |
print $ dice gen | |
print $ threeTimesDiceRoll gen | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment