Hi,
I needed a function that returns True/False if a list of strings are in a given string. I made one function below (works fine),..but I was wondering whether there is a shorter way?
-- |Returns True if one of given strings are contained in given string
contains :: [String] -> String -> Bool
contains elements seach_elem
| trueListCount == 0 = False
| otherwise = True
where
isInStringList = [isInfixOf elem seach_elem | elem <- elements]
onlyTrueList = [elem | elem <- isInStringList, elem == True]
trueListCount = length onlyTrueList
Cheers,
-m