Skip to content

Instantly share code, notes, and snippets.

@petermarks
Created September 20, 2010 20:46
Show Gist options
  • Save petermarks/588622 to your computer and use it in GitHub Desktop.
Save petermarks/588622 to your computer and use it in GitHub Desktop.
Number guesser
module Main where
makeAGuess :: Int -> Int -> Int
makeAGuess i j = (i + j) `div` 2
guess :: Int -> Int -> IO ()
guess i j = do
let x = makeAGuess i j
putStrLn (show x)
response <- getLine
case response of
"Low" -> guess x j
"High" -> guess i x
otherwise -> return ()
main :: IO ()
main = do
getLine
guess 1 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment