Skip to content

Instantly share code, notes, and snippets.

@wlangstroth
Created May 31, 2010 03:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlangstroth/419501 to your computer and use it in GitHub Desktop.
Save wlangstroth/419501 to your computer and use it in GitHub Desktop.
import System.Random
randPairs :: (RandomGen g, Random a) => (a,a) -> g -> [(a,a)]
randPairs range gen = zip as bs
where (a,b) = split gen -- create two separate generators
as = randomRs range a -- one infinite list of randoms
bs = randomRs range b -- another
seed = 13561956 :: Int
mygen = mkStdGen seed
coords :: [(Int,Int)]
coords = take 50 $ -- 50 random coordinates derived
randPairs (1,100) mygen -- from the random seed above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment