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:
8a37d80
)
Make intersectBy lazier
author
Daniel Fischer
<daniel.is.fischer@web.de>
Thu, 30 Sep 2010 19:17:31 +0000
(19:17 +0000)
committer
Daniel Fischer
<daniel.is.fischer@web.de>
Thu, 30 Sep 2010 19:17:31 +0000
(19:17 +0000)
Add shortcuts to intersectBy for empty list arguments.
In addition to being faster in that case, more inputs yield defined results.
Treats ticket #4323
Data/List.hs
patch
|
blob
|
history
diff --git
a/Data/List.hs
b/Data/List.hs
index
cc166d8
..
c954757
100644
(file)
--- a/
Data/List.hs
+++ b/
Data/List.hs
@@
-410,6
+410,8
@@
intersect = intersectBy (==)
-- | The 'intersectBy' function is the non-overloaded version of 'intersect'.
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
+intersectBy _ [] _ = []
+intersectBy _ _ [] = []
intersectBy eq xs ys = [x | x <- xs, any (eq x) ys]
-- | The 'intersperse' function takes an element and a list and