Skip to content

Instantly share code, notes, and snippets.

@m2ym
Created November 14, 2010 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m2ym/675897 to your computer and use it in GitHub Desktop.
Save m2ym/675897 to your computer and use it in GitHub Desktop.
import Control.Monad
import Control.Applicative
import System.Random
randomRnIO :: Random a => Int -> (a, a) -> IO [a]
randomRnIO n r = sequence $ replicate n (randomRIO r)
points :: IO [(Int, Int)]
points = liftM2 zip (randomRnIO 10 (0, 100)) (randomRnIO 10 (0, 100))
main = do
print =<< points
print =<< points -- Different output
ps <- points
print ps
print ps -- Same output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment