"A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal: Panama!" - T. Roosevelt
levelis a palindrome. The idea of a palindrome can be extended to phrases or sentences if we ignore details like punctuation. Here are two familiar examples:
Madam, I'm Adam A man, a plan, a canal: PanamaWe can recognize these more elaborate examples as palindromes by considering the text that is obtained by removing all spaces and punctuation marks and converting all letters to their lower-case form.
Madam, I'm Adam ==> madamimadam A man, a plan, a canal: Panama ==> amanaplanacanalpanamaIf the "word" obtained from a phrase in this manner is a palindrome, then the phrase is a palindrome. The punctuation characters that should be ignored are comma (,), colon (:), and the apostrophe (').
For this programming assignment you should construct a Haskell script Prog1.hs that contains a function palindrome:
-- palindrome s is True if sentence s is a palindrome and False otherwise palindrome :: String -> Bool
You may find it helpful to include the function strip in the script, to be used in the construction of function palindrome:
-- strip s is the string obtained by removing all punctuation and -- spaces from s and converting all characters of the alphabet -- to their lower case form. strip :: String -> String
Test your program on the inputs at the top of the page and any others that you might be able to think of. For example:
Prog1> palindrome "level" True Prog1> palindrome "Madam, I'm Adam" True Prog1> palindrome "Not a ton!" False