From 098eed7b6cd4e7833b4f51b0dbd1303ec65b54bd Mon Sep 17 00:00:00 2001 From: Gauravsingh Sisodia <65955464+gauravsingh5@users.noreply.github.com> Date: Sat, 27 Mar 2021 22:49:27 +0530 Subject: [PATCH] Add Haskell Palindrome (#120) --- strings/README.md | 4 ++++ strings/haskell/palindrome.hs | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 strings/haskell/palindrome.hs diff --git a/strings/README.md b/strings/README.md index 4f50bc2a..39e1a7ac 100644 --- a/strings/README.md +++ b/strings/README.md @@ -32,3 +32,7 @@ 1. [Palindrome Check](rust/palindrome/README.md) +### Haskell + +1. [Palin Check](haskell/palindrome.hs) + diff --git a/strings/haskell/palindrome.hs b/strings/haskell/palindrome.hs new file mode 100644 index 00000000..5db4e5f3 --- /dev/null +++ b/strings/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"]