Created
April 5, 2014 12:39
-
-
Save gouf/9991455 to your computer and use it in GitHub Desktop.
Haskell 練習
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
madam = "Madam, I'm Adam." | |
remove chr str = [c | c <- str, c /= chr] | |
removeCommas str = remove ',' str | |
removeBlanks str = remove ' ' str | |
removePeriods str = remove '.' str | |
{-- | |
removeCommas str = [c | c <- str, c /= ','] | |
removeBlanks str = [c | c <- str, c /= ' '] | |
removePeriods str = [c | c <- str, c /= '.'] | |
--} | |
removeBPC str = ((removeCommas.removeBlanks.removePeriods) str) | |
removeAd str = (remove 'A'. remove 'd') str | |
main = do | |
print $ madam | |
print (removeCommas(madam)) | |
print (removeBPC madam) | |
print $ remove '\'' madam | |
print $ removeAd madam | |
--- Output | |
{-- | |
"Madam, I'm Adam." | |
"Madam I'm Adam." | |
"MadamI'mAdam" | |
"Madam, Im Adam." | |
"Maam, I'm am." | |
--} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment