[Haskell-beginners] Randomness, lists, and unfoldr
rpglover64 at gmail.com
Mon Sep 13 14:42:49 EDT 2010
I'm trying to build a list where each entry depends on the previous one.
Unfoldr seemed like a good idea at the time.
Unfortunately, my values are monadic values (specifically RVars, from the
random-fu package). Okay, shouldn't be a problem; I just monadic bind
> -- example code
> updateCell :: Bool -> RVar Bool
> updateCell False = return False
> updateCell True = bernoulli (0.9 :: Double)
> sim = sequence $ take 20 $ unfoldr (\x -> Just (x, x >>= updateCell))
> runRVar sim DevURandom
That output shouldn't be possible if I'm doing things right... It appears
that each cell has an independent history. I'm stumped.
Advice on threading monad input in general and random-fu in specific would
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners