Skip to content

Instantly share code, notes, and snippets.

@priort
Created December 30, 2018 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save priort/cda52093a1998d736f7a3b03e9da2c7a to your computer and use it in GitHub Desktop.
Save priort/cda52093a1998d736f7a3b03e9da2c7a to your computer and use it in GitHub Desktop.
isPalindrome :: String -> Bool
isPalindrome [] = True
isPalindrome (x : []) = True
isPalindrome (x1 : x2 : []) = x1 == x2 -- this line is not necessary, thanks Szymon
isPalindrome (x1 : xs) = x1 == last xs && isPalindrome (init xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment