Skip to content

Commit

Permalink
Make intersectBy lazier
Browse files Browse the repository at this point in the history
Add shortcuts to intersectBy for empty list arguments.
In addition to being faster in that case, more inputs yield defined results.
Treats ticket #4323
  • Loading branch information
Daniel Fischer committed Sep 30, 2010
1 parent 6cc96ac commit 8e81282
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/base/Data/List.hs
Expand Up @@ -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
Expand Down

0 comments on commit 8e81282

Please sign in to comment.