Skip to content

Instantly share code, notes, and snippets.

@sadhu89
Created October 2, 2016 03:11
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 sadhu89/588ebcf606b8caa864404277a10d3337 to your computer and use it in GitHub Desktop.
Save sadhu89/588ebcf606b8caa864404277a10d3337 to your computer and use it in GitHub Desktop.
import System.Random
starman :: Int -> IO ()
starman n = do
g <- newStdGen
words = ["hello", "world", "haskell"]
word = words!!(fst (randomR (0,(length words) - 1) g))
turn word ['-' | x <- word] n
@BillyBadBoy
Copy link

BillyBadBoy commented Oct 2, 2016

try this :

import System.Random

starman :: Int -> IO ()
starman n = do
  let words = ["hello", "world", "haskell"]
  i <- getStdRandom (randomR (0, length words - 1))
  let word = words !! i
  turn word ['-' | x <- word] n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment