HASKELL   15

hilo2

Guest on 22nd September 2022 12:24:22 AM

  1. module Main
  2.         where
  3.  
  4. import IO
  5. import Random
  6.  
  7. main = do
  8.         hSetBuffering stdin LineBuffering
  9.         num <- randomRIO (1::Int, 100)
  10.         putStrLn "I’m thinking of a number between 1 and 100" 100"
  11.         doGuessing num
  12.  
  13. doGuessing num = do
  14.         putStrLn "Enter your guess:"
  15.         guess <- getLine
  16.         if (read guess) < num
  17.                 then do putStrLn "Too low!"
  18.                         doGuessing num
  19.                 else if read guess > num
  20.                         then do putStrLn "Too high!"
  21.                                 doGuessing num
  22.                 else do putStrLn "You

Raw Paste


Login or Register to edit or fork this paste. It's free.