Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import Data.Monoid (Sum(..))
import System.Random (randomIO)
import Control.Monad (replicateM)
import Data.Bool (bool)
data Toss = Heads | Tails deriving Show
anExperiment toss =
moreWakenings <>
case toss of
Heads -> headsOnWaking
Tails -> moreWakenings
where
moreWakenings = (1,0)
headsOnWaking = (0,1)
main = do
tosses <- map (bool Heads Tails) <$> replicateM 1000000 randomIO
let (Sum w, Sum h) = foldMap anExperiment tosses
let ratio = fromIntegral h / fromIntegral w
putStrLn $ "Ratio: " ++ show ratio