@@ -36,3 +36,17 @@ isElem x (y :: xs) with (decEq x y)
36 Elem x' (y' :: xs') -> Void
36 Elem x' (y' :: xs') -> Void
37 mkNo f g Here = f Refl
37 mkNo f g Here = f Refl
38 mkNo f g (There x) = g x
38 mkNo f g (There x) = g x
40+intersectBy : (a -> a -> Bool) -> List a -> List a -> List a
41+intersectBy _ [] _ = []
42+intersectBy _ _ [] = []
43+intersectBy eq xs ys = [x | x <- xs, any (eq x) ys]
45+||| The intersect ∩ function returns the list intersect of the two lists. For example,
48+||| intersect [1,2,3,4] [2,4,6,8]
51+intersect : (Eq a) => List a -> List a -> List a
52+intersect = intersectBy (==)