diff options
author | Daniel Fischer <daniel.is.fischer@web.de> | 2010-09-30 19:17:31 +0000 |
---|---|---|
committer | Daniel Fischer <daniel.is.fischer@web.de> | 2010-09-30 19:17:31 +0000 |
commit | 8e8128252ee5d91a73526479f01ace8ba2537667 (patch) | |
tree | 90ac127e9c30b9b496c97956a278912cfb125d22 /libraries/base/Data/List.hs | |
parent | 6cc96ac7a14174cf7ad68f5fcdda4e1061007d6a (diff) | |
download | haskell-8e8128252ee5d91a73526479f01ace8ba2537667.tar.gz |
Make intersectBy lazier
Add shortcuts to intersectBy for empty list arguments.
In addition to being faster in that case, more inputs yield defined results.
Treats ticket #4323
Diffstat (limited to 'libraries/base/Data/List.hs')
-rw-r--r-- | libraries/base/Data/List.hs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs index cc166d80de..c954757ddd 100644 --- a/libraries/base/Data/List.hs +++ b/libraries/base/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 |