Created
May 27, 2015 12:00
-
-
Save shigemk2/522761484fb822d1a409 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 | |
threeCoins :: StdGen -> (Bool, Bool, Bool) | |
threeCoins gen = | |
-- genを渡しては受け取り、っていうのを繰り返す | |
let (firstCoin, newGen) = random gen | |
(secondCoin, newGen') = random newGen | |
(thirdCoin, newGen'') = random newGen' | |
in (firstCoin, secondCoin, thirdCoin) | |
main = do | |
-- 種が一緒だから返ってくる値も一緒 | |
print $ threeCoins (mkStdGen 21) | |
print $ threeCoins (mkStdGen 21) | |
print $ threeCoins (mkStdGen 22) | |
print $ threeCoins (mkStdGen 543) | |
print $ threeCoins (mkStdGen 544) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment