#include "fusion-phases.h"
module Data.Array.Parallel.Stream.Flat.Random (
randomS, randomRS
) where
import Data.Array.Parallel.Base
import Data.Array.Parallel.Stream.Flat.Stream
import System.Random
randomS :: (RandomGen g, Random a) => Int -> g -> Stream a
randomS n g = Stream step (Lazy g :*: n) n
where
step (Lazy g :*: 0) = Done
step (Lazy g :*: n) = let (x,g') = random g
in Yield x (Lazy g' :*: (n1))
randomRS :: (RandomGen g, Random a) => Int -> (a,a) -> g -> Stream a
randomRS n r g = Stream step (Lazy g :*: n) n
where
step (Lazy g :*: 0) = Done
step (Lazy g :*: n) = let (x,g') = randomR r g
in Yield x (Lazy g' :*: (n1))