过滤字母替换空格和小写字母的符号

时间:2015-05-06 17:00:35

标签: haskell filter words letter

示例:"Paul's! Come There"

GetOutput:"paul s come there"

 myFilter :: String -> String
 myFilter str = unwords . filter (not . null) . map (
                              map toLower . filter  isLetter
                              ) . words $ str

如何将字母过滤到lowerCase中,同时用空格替换所有非字符号?

1 个答案:

答案 0 :(得分:1)

@Cirdec这个想法。要使语法正确,将是map      Hello! (注意括号)与(\c -> if not (isLetter c) then ' ' else c)

相同