Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created May 27, 2015 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/522761484fb822d1a409 to your computer and use it in GitHub Desktop.
Save shigemk2/522761484fb822d1a409 to your computer and use it in GitHub Desktop.
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