Skip to content
Snippets Groups Projects
Commit 4299243f authored by sof's avatar sof
Browse files

[project @ 1997-10-21 20:31:47 by sof]

unionBy: remove duplicates in second argument (required for the following invariant to hold: if the first list argument contain no duplicates, then the result of applying unionBy doesn't either)
parent 128e3070
No related merge requests found
......@@ -8,7 +8,7 @@
module List (
{-
This list follows the type signatures for the
standard List interface.
standard List interface. -- 8/97
-}
elemIndex, elemIndices,
find, findIndex, findIndices,
......@@ -16,10 +16,10 @@ module List (
delete, deleteBy, (\\), deleteFirstsBy,
union, unionBy,
intersect, intersectBy,
intersperse, transpose, partition,
group, groupBy,
inits, tails,
isPrefixOf, isSuffixOf,
intersperse, transpose, partition,
mapAccumL, mapAccumR,
sort, sortBy,
insertBy,
......@@ -117,7 +117,7 @@ union :: (Eq a) => [a] -> [a] -> [a]
union = unionBy (==)
unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
unionBy eq xs ys = xs ++ foldl (flip (deleteBy eq)) ys xs
unionBy eq xs ys = xs ++ foldl (flip (deleteBy eq)) (nubBy eq ys) xs
intersect :: (Eq a) => [a] -> [a] -> [a]
intersect = intersectBy (==)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment