tom.davie at gmail.com
Sat Oct 24 20:25:58 EDT 2009
Or just randomRs :: (Random a, RandomGen g) => (a,a) -> g -> [a]
On Sun, Oct 25, 2009 at 2:05 AM, Brent Yorgey <byorgey at seas.upenn.edu>wrote:
> On Sat, Oct 24, 2009 at 05:59:35PM +0100, John Moore wrote:
> > Hi All,
> > Can anyone help me I want to produce a list of three random
> > numbers for e.g. [7,8,1]
> > I tried using x <- getStdRandom $ randomR (1,10) but don't really
> > this and it only generates one number. Any help greatly appreciated.
> replicateM is your friend:
> replicateM :: (Monad m) => Int -> m a -> m [a]
> so if 'foo' produces a single random number, then 'replicateM 3 foo'
> produces a list of three.
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners