Browse thread
Sets and home-made ordered types
- Matthias Puech
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Matthias Puech <puech@c...> |
| Subject: | Sets and home-made ordered types |
Dear Camlists,
This is my first post on this list, so please excuse me if it is too
vague/off-topic/already discussed... I've been asking myself this
question about the standard library's Set for quite a while.
The ability of the module Set to take an order (compare) as input,
possibly larger than Pervasive's one, allows for some valuable tricks,
i.e. assure that a set contains at most one element of each equivalence
class. This element is actually stored in the structure, but then it
seems not possible to retreive it (efficiently): the only interaction is
to test if some element of the same equivalence class is present, with
mem : elt -> t -> bool.
My question is : why isn't there a function find : elt -> t -> elt,
where find e s would return the stored element e' s.t compare e e' = 1
? These two elements can be interestingly distinct though...
Thanks in advance for all enlightenment.
--Matthias
PS: Of course I don't want to fold, filter or such, for efficiency
reasons...