[Haskell-cafe] Re: Deleting list of elements from Data.Set

Gracjan Polak gracjanpolak at gmail.com
Wed Jan 30 09:18:32 EST 2008

Duncan Coutts <duncan.coutts <at> worc.ox.ac.uk> writes:
> Data.List.foldr (Data.Set.delete) s [1,3,5]
> or
> Data.List.foldl' (flip Data.Set.delete) s [1,3,5]

There will be a day when I finally grasp foldr/foldl :)
> which is O (n + m * log m) rather than O(m * log n) or if the elements
> you're deleting are already sorted you can shave off the log m using
> Data.Set.fromAscList to get just O (n + m).

Thanks for advice. My data is sorted so the above applies really well.


More information about the Haskell-Cafe mailing list