Standard Library report: List union

Jon Fairbairn Jon.Fairbairn@cl.cam.ac.uk
Sun, 17 Mar 2002 19:06:44 +0000


> There's a remark at the beginning of 7.2 that says:
> =

> delete, (\\), union and intersect preserve the invariant=3D20
> that lists don't contain duplicates, provided that=3D20
> their first argument contains no duplicates.
> =

> The same applies to unionBy etc.   This design is one
> you might reasonably disagree with.  I'd have thought
> it would be more sensible to have the invariant that
> *both* arguments to union and intersect are assumed
> to be sets (no dups). =


That's partly what I was alluding to, but either way I'd
have thought that there were clearer definitions, for
example:


unionBy eq xs ys =3D xs ++ [y | y <- nubBy eq ys, not (any (eq y) xs)]



J=F3n

-- =

J=F3n Fairbairn                                 Jon.Fairbairn@cl.cam.ac.u=
k
31 Chalmers Road                                         jf@cl.cam.ac.uk
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)