Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main :: IO()
- main = do
- printInfo
- printInfo :: IO()
- printInfo = do
- input <- getLine
- if input /= "End" then
- do
- let info = printDigit input
- putStrLn (show info)
- printInfo
- else
- putStr ""
- printDigit :: String -> String
- printDigit "0" = "Zero"
- printDigit "1" = "One"
- printDigit "2" = "Two"
- printDigit "3" = "Three"
- printDigit "4" = "Four"
- printDigit "5" = "Five"
- printDigit "6" = "Six"
- printDigit "7" = "Seven"
- printDigit "8" = "Eight"
- printDigit "9" = "Nine"
- printDigit _ = "Please only enter single digit positive numbers"
- printDigit2 :: String -> String
- printDigit2 n = case n of
- "0" -> "Zero"
- "1" -> "One"
- "2" -> "Two"
- "3" -> "Three"
- "4" -> "Four"
- "5" -> "Five"
- "6" -> "Six"
- "7" -> "Seven"
- "8" -> "Eight"
- "9" -> "Nine"
- _ -> "Please only enter single digit positive numbers"
- printDigit3 :: Int -> String
- printDigit3 n
- | n >= 0 && n <= 9 = list !! n
- | otherwise = "Please only enter single digit positive numbers"
- where
- list = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement