Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Map + Set
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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 (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, 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 

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: