#4323: Change implementation of intersectBy
----------------------------------+-----------------------------------------
Reporter: daniel.is.fischer | Owner:
Type: proposal | Status: new
Priority: normal | Component: libraries/base
Version: 6.12.3 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
----------------------------------+-----------------------------------------
Currently, intersectBy eq xs [] takes O(length xs) time to calculate and
returns _|_ on (x : _|_). The proposed change,
{{{
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
intersectBy _ [] _ = []
intersectBy _ _ [] = []
intersectBy eq xs ys = [x | x <- xs, any (eq x) ys]
}}}
makes this an O(1) operation and returns [] for infinite or partial (... :
_|_) lists xs. The first equation is necessary to retain intersectBy _ []
_|_ = [].
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4323>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs