| > The stream-based approach has its problems if one requires random
| > values of different types. If this is vital one automatically starts to
| > use functions of type Seed -> (value, Seed).
| I don't understand at all.  Why would random values of different types
| require that signature?  Why can you use an infinite list of these
| other values?  Why can't you take the [Int] list of random numbers
| and transform it into whatever you want?  That's what I do.

I guess you would end up with nearly the same code (unless I overlook
an obvious alternative in which case I would love to see the simple and
straightforward solution ;-). Let's be concrete: say you need n
Integers within range (l, r), m Ints and p Doubles. Using a monad-based
approach one writes

        ...
        mis <- accumulate [ randomInteger (l, r) | i <- [1 .. n] ]
        is  <- accumulate [ randomInt | i <- [1 .. m] ]
        ds  <- accumulate [ randomDouble | i <- [1 .. p] ]
        return (mis, is, ds)

What's your solution based on an [Int] list of random numbers?

Ralf


Reply via email to