Cleaner isInfixOf suggestion from Ross Paterson
authorJohn Goerzen <jgoerzen@complete.org>
Fri, 1 Sep 2006 14:36:54 +0000 (14:36 +0000)
committerJohn Goerzen <jgoerzen@complete.org>
Fri, 1 Sep 2006 14:36:54 +0000 (14:36 +0000)
Data/List.hs

index 8b504f7..7c3cede 100644 (file)
@@ -276,7 +276,7 @@ isSuffixOf x y          =  reverse x `isPrefixOf` reverse y
 -- >isInfixOf "Haskell" "I really like Haskell." -> True
 -- >isInfixOf "Ial" "I really like Haskell." -> False
 isInfixOf               :: (Eq a) => [a] -> [a] -> Bool
-isInfixOf needle haystack = isJust $ find (isPrefixOf needle) (tails haystack)
+isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack)
 
 -- | The 'nub' function removes duplicate elements from a list.
 -- In particular, it keeps only the first occurrence of each element.