From: John Goerzen Date: Fri, 1 Sep 2006 14:36:54 +0000 (+0000) Subject: Cleaner isInfixOf suggestion from Ross Paterson X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=115f2822388b798fb2adb8946a40d55782b0d0a8;p=ghc-base.git Cleaner isInfixOf suggestion from Ross Paterson --- diff --git a/Data/List.hs b/Data/List.hs index 8b504f7..7c3cede 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -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.