Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created May 27, 2015
Embed
What would you like to do?
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