Skip to content

Instantly share code, notes, and snippets.

@JankDev
Created April 26, 2020 20:38
Show Gist options
  • Save JankDev/38fbcd0b5853e180169944e0ee599226 to your computer and use it in GitHub Desktop.
Save JankDev/38fbcd0b5853e180169944e0ee599226 to your computer and use it in GitHub Desktop.
import System.Random
main = do
num <- randomIO :: IO Int
sequence [guess num | i <- [1..3]]
guess num = do
putStrLn "What's your guess"
line <- getLine
let userGuess = read line :: Int
putStrLn $ compare' num userGuess
compare' :: Int -> Int -> String
compare' num guess
| comparison == LT = "Too low"
| comparison == GT = "Too high"
| otherwise = "You got it"
where comparison = num `compare` guess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment