2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
4 \section[ListSetOps]{Set-like operations on lists}
7 #include "HsVersions.h"
11 --UNUSED: intersectLists,
18 import Util ( isIn, isn'tIn )
20 #if __GLASGOW_HASKELL__ >= 202
26 unionLists :: (Eq a) => [a] -> [a] -> [a]
27 #ifdef REALLY_HASKELL_1_3
34 | a `is_elem` b = unionLists as b
35 | otherwise = a : unionLists as b
37 is_elem = isIn "unionLists"
41 intersectLists :: (Eq a) => [a] -> [a] -> [a]
42 intersectLists [] [] = []
43 intersectLists [] b = []
44 intersectLists a [] = []
45 intersectLists (a:as) b
46 | a `is_elem` b = a : intersectLists as b
47 | otherwise = intersectLists as b
49 is_elem = isIn "intersectLists"
53 Everything in the first list that is not in the second list:
55 minusList :: (Eq a) => [a] -> [a] -> [a]
56 minusList xs ys = [ x | x <- xs, x `not_elem` ys]
58 not_elem = isn'tIn "minusList"