[英]Is there a way to selectList without any filter or select options in Persistent Haskell?
[英]Is there any way we can lowerCase the string while using filter in haskell
我在Haskell中有一個函數,該函數接受字符串,並從中刪除特定字符后,返回字符串中的字符列表。 有什么辦法可以使輸出為小寫?
請參閱下面的功能:
getList s = filter (\w -> w `notElem` [",.?!-:;\"\'",]) (words s)
從Data.Char
使用toLower :: Char -> Char
:
lowerCase :: String -> String
lowerCase = map toLower
只需將getList
應用於lowerCase s
而不是s
。
我不認為您的職能正在發揮您的意圖
你可以重寫為
getList = map (map toLower . filter (`notElem` ",.?!-:;'\"")) . words
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.