intersectionSet, differenceSet

Milan Straka fox at ucw.cz
Fri Nov 16 08:40:27 CET 2012


> On Thu, 15 Nov 2012, Andreas Abel wrote:
> 
> >Sounds ok, by why especially for Set.  Why not (also)
> >
> >   Map.intersectionList :: Ord k => Map k a -> [k] -> Map k a
> >   Map.differenceList :: Ord k => Map k a -> [k] -> Map k a
> >
> >? Screams for a generalization.
> 
> I assume that Map.differenceSet can make use of the internal tree
> structure of a set and is thus more efficient. The documentation of
> Map.difference says it uses an adaption of hedge-union and this
> could also be used for Map.differenceSet.

This is true for Map and Set, although the difference versus
  Map.insersection m (fromSet (const ()) s)
will be probably minor.

It is not the case for IntMap and IntSet, as these has different
representation.

Cheers,
Milan



More information about the Libraries mailing list