Add Haskell Palindrome (#120)
parent
89b7afb0cf
commit
098eed7b6c
|
@ -32,3 +32,7 @@
|
|||
|
||||
1. [Palindrome Check](rust/palindrome/README.md)
|
||||
|
||||
### Haskell
|
||||
|
||||
1. [Palin Check](haskell/palindrome.hs)
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
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"]
|
Loading…
Reference in New Issue