Files
book-exercises/Haskell-book/13/Palindrome.hs

21 lines
442 B
Haskell

module Palindrome where
import Control.Monad
import Data.Char
import System.Exit
format :: String -> String
format s = filter (\x -> x >= 'a' && x <= 'z') (map toLower s)
palindrome :: IO ()
palindrome = forever $ do
line1 <- getLine
case ((format line1) == (format $ reverse line1)) of
True -> putStrLn "It's a palindrome!"
False -> do
putStrLn "Nope!"
exitSuccess
main :: IO ()
main = palindrome