Skip to content

Instantly share code, notes, and snippets.

@reiddraper
Created August 14, 2011 21:13
Show Gist options
  • Save reiddraper/1145318 to your computer and use it in GitHub Desktop.
Save reiddraper/1145318 to your computer and use it in GitHub Desktop.
isPalindrome :: (Eq a) => [a] -> Bool
isPalindrome [] = True
isPalindrome [x] = True
isPalindrome (x:xs) = (x == last xs) && (isPalindrome $ init xs)
@md2perpe
Copy link

Easier and more efficient:

isPalindrome xs = xs == reverse xs

@reiddraper
Copy link
Author

@md2perpe ah yes, thanks.

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