Skip to content

Instantly share code, notes, and snippets.

@nattybear
Created March 2, 2022 11:16
Show Gist options
  • Save nattybear/2061b56b48a82ce56f917ece140b4ef4 to your computer and use it in GitHub Desktop.
Save nattybear/2061b56b48a82ce56f917ece140b4ef4 to your computer and use it in GitHub Desktop.
palindromes.hs
respondPalindromes :: String -> String
respondPalindromes =
unlines .
map (\xs -> if isPal xs then "palindrome" else "not a palindrome") .
lines
isPal :: String -> Bool
isPal xs = xs == reverse xs
main = interact respondPalindromes
@nattybear
Copy link
Author

$ runhaskell palindromes.hs
hehe
not a palindrome
ABCBA
palindrome
cookie
not a palindrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment