
3 Jan
2010
3 Jan
'10
12:46 p.m.
I want to set a random seed for a random number generator. I tried this: getSeed = do time <- getClockTime return (ctPicosec (toUTCTime time)) seed <- getSeed randList minval maxval = randomRs (minval,maxval) (mkStdGen seed) But I get the error: parse error on input `<-' which refers to "seed<-getSeed". Using "seed<-getSeed" from the ghci command line works. Why doesn't it work in a script? THe second problem is the seed is of type Integer but mkStdGen wants an Int. How can I get an Int from an Integer? I tried mod to get the seed to within range for an int but the result is still of type Integer how can I coerce Integer to Int when I know result will fit? Thanks