projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7a4646e
)
Cleaner isInfixOf suggestion from Ross Paterson
author
John Goerzen
<jgoerzen@complete.org>
Fri, 1 Sep 2006 14:36:54 +0000
(14:36 +0000)
committer
John Goerzen
<jgoerzen@complete.org>
Fri, 1 Sep 2006 14:36:54 +0000
(14:36 +0000)
Data/List.hs
patch
|
blob
|
history
diff --git
a/Data/List.hs
b/Data/List.hs
index
8b504f7
..
7c3cede
100644
(file)
--- 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 "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.
-- | The 'nub' function removes duplicate elements from a list.
-- In particular, it keeps only the first occurrence of each element.