Created
April 26, 2020 20:38
-
-
Save JankDev/38fbcd0b5853e180169944e0ee599226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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