Examples/Random list

From HaskellWiki
Revision as of 03:10, 31 January 2007 by DonStewart (talk | contribs) (more code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Generate a random list of numbers, without using the System.Random.randoms method:

import System.Random
import Data.List

main = do
    seed  <- newStdGen
    let rs = randomify 10 seed
    print rs

randomlist :: Int -> StdGen -> [Int]
randomlist n = take n . unfoldr (Just . random)