
16 Sep
2010
16 Sep
'10
12:16 p.m.
On 16 September 2010 17:10, Bas van Dijk
However I like using a 'filter' more than using a list comprehension:
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] intersectBy _ [] _ = [] intersectBy _ _ [] = [] intersectBy eq xs ys = filter (\x -> any (eq x) ys) xs
Hopefully this definition can even benefit from foldr/build fusion using the filter RULES in GHC.List:
It should not make any difference. List comprehensions can also be fused using foldr/build fusion because the list combrehension is desugared into uses of foldr and build. It is also unlikely to fuse anyway because the compiler would need to know at the call site that the two lists are non-empty. Duncan