Reputation: 275
Right now I have this piece of code: filter (any ('elem' "abc")) [String]
. This checks to see if an element from [String] contains 'a' or 'b' or 'c', which returns as true, but this isn't exactily what I need. I want to see if it contains 'a' and 'b' and 'c'. the "all" function won't work because it would check if everything was 'a' or 'b' or 'c', which means something like "abcd" would return false which I don't want. Ty.
Upvotes: 1
Views: 75
Reputation: 476977
You should swap the "abc"
and `"abcdefg" part:
all (`elem` "abcdefg") "abc"
this thus checks if 'a'
, 'b'
and 'c'
are all elements of the "abcdefg"
string.
Or you can filter a list of strings with:
filter (\x -> all (`elem` x) "abc") ["abcdef", "acdef"]
Upvotes: 2