DSA/algorithms/Haskell/strings/palindrome.hs

11 lines
252 B
Haskell
Raw Normal View History

2021-03-27 17:19:27 +00:00
import Control.Monad (ap)
isPalindrome :: String -> Bool
isPalindrome s = s == reverse s
-- point-free style
isPalindrome2 :: String -> Bool
isPalindrome2 = ap (==) reverse
main = traverse print $ isPalindrome <$> ["abba", "abbcccbba", "abbccbbba"]