| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
TFwH.Chap02.ExI
Description
第2章 練習問題 I
入力文字列が回文になっているかを判定する対話プログラム
palindrome :: IO ()を書けimport Data.Char parindrome :: IO () prindrome = do { putStrLn "Enter a string:" ; xs <- getLine ; if isPalindrome xs then putStrLn "Yes!" else putStrLn "No!" } isPalindrome :: String -> Bool isPalindrome xs = (ys == reverse ys) where ys = map toLower (filter isAlpha xs)
- palindrome :: IO ()
- isPalindrome :: String -> Bool
Documentation
palindrome :: IO () Source #
入力文字列が回文になっているかを判定する対話プログラム
isPalindrome :: String -> Bool Source #
文字列が回文かどうかを判定する述語
>>>isPalindrome "Madam, I'm Adam"True>>>isPalindrome "A Man, a plan, a canal - Suez!"False>>>isPalindrome "A Man, a plan, a canal - Panama"True