Browse thread
[Caml-list] Map + Set
[
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: | Brian Hurt <bhurt@s...> |
| Subject: | Re: [Caml-list] Map + Set |
On Mon, 26 Jul 2004, Matthieu Sozeau wrote:
> On Sun, Jul 25, 2004 at 12:01:03PM -0500, Brian Hurt wrote:
> > On Sun, 25 Jul 2004, Martin Jambon wrote:
> >
> > A better interface might be:
> >
> > val find: (elt -> int) -> t -> elt
>
> Why an int ? Isn't a boolean enough ?
Two reasons:
1) This allows you to use Pervasives.compare (or other compatible
function) partially applied.
2) In addition to equality, you also need less than/greater than in order
to keep the function in O(log N)- which branch do you descend? With just
equality, you need to do an O(N) exhaustive search.
>
> > There is a lot of functionality I'd like to be able to add to map and set.
> > I find myself reimplementing them on a regular basis myself (and no, I
> > haven't thought of a better solution).
>
> Apart from "val of_list : elt list -> t" (a one liner) and the find
> function (a fold with an exception or using `exists` and keeping a
> reference, which indicates, I think, that it should be implemented
> directly in set.ml), i don't remember truly missing functions.
> What are those ?
Map, fold, and iter over pairs of maps or sets is the one I always end up
needing. Also, enums would be nice. Actually, I could do the pairwise
comprehensions if I had enums.
>
> > Many people on this list don't like modules, however.
>
> That seems like a weird opinion to me, and mine is that most OCaml hackers
> are really caml hackers who don't want to know about the OO part.
>
When I tossed out my changes to map and set, they were bounced with a
"they use modules- you should apply them to the demodulized versions of
the code instead". And about the only feed back I ever got on priority
search queues amounted to "it uses modules- we don't like modules".
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners