haskell: filtering Strings with a certain symbol e.g '!' in a List? -
i have list of strings : ["1*1", "ab!c", "cde2", "efghi!"]
want sort out every string '!'
. first idea : filter (map elem '!' (list)) list
string map elem '!' (list), thats not working because checkups string , not elements of strings in list...
thanks help!
you mapped much.
filter ('!' `elem`) list
should work you....
explanation:
you have list of strings [string]
. string list of chars, because string = [char]
...
so have list of lists. [[char]]
since elem works checking if single element exists in list, can call elem
on each list item outer list.
Comments
Post a Comment