Set.lookup?
Christian Maeder
maeder at tzi.de
Thu Sep 15 08:40:25 EDT 2005
Serge D. Mechveliani wrote:
> How do you think, maybe, Data.Set also needs to provide
> `lookup' ?
Admittingly, using 'Set.filter (==e) s' to find the matching element may
be a bit slower.
When trying to use 'Set.intersection s $ singleton e' I just noticed
that intersection is not left-biased (see below)!
I'm not sure if Data.Set should be extended to better support elements
with an equivalence relation and a corresponding order. I've such sets
too, but never really cared about the additional component.
Do you also want functions 'insertWith', 'unionWith', 'splitLookup' (and
what not)?
I'ld rather suggest to use Data.Map instead and use a proper total order
for the keys (although that may also be awkward).
Christian
*Main> findMin $ union (singleton $ D 0 "3") $ singleton $ D 0 "2"
D 0 "3"
*Main> findMin $ intersection (singleton $ D 0 "3") $ singleton $ D 0 "2"
D 0 "2"
More information about the Glasgow-haskell-users
mailing list