Sleeping Beauty problem: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: added solution) |
m (→{{header|Haskell}}: small simplification) |
||
Line 312: | Line 312: | ||
data Toss = Heads | Tails deriving Show |
data Toss = Heads | Tails deriving Show |
||
⚫ | |||
sleepingBeautyExperiment = foldMap anExperiment |
|||
moreWakenings <> |
|||
case toss of |
|||
⚫ | |||
⚫ | |||
where |
where |
||
⚫ | |||
case toss of |
|||
⚫ | |||
⚫ | |||
moreWakenings = (1,0) |
moreWakenings = (1,0) |
||
headsOnWaking = (0,1) |
headsOnWaking = (0,1) |
||
Line 323: | Line 323: | ||
main = do |
main = do |
||
tosses <- map (bool Heads Tails) <$> replicateM 1000000 randomIO |
tosses <- map (bool Heads Tails) <$> replicateM 1000000 randomIO |
||
let (Sum w, Sum h) = |
let (Sum w, Sum h) = foldMap anExperiment tosses |
||
let ratio = fromIntegral h / fromIntegral w |
let ratio = fromIntegral h / fromIntegral w |
||
putStrLn $ "Ratio: " ++ show ratio</lang> |
putStrLn $ "Ratio: " ++ show ratio</lang> |