From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA10865; Mon, 26 Jul 2004 18:19:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA11228 for ; Mon, 26 Jul 2004 18:19:36 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6QGJ7SH018168 for ; Mon, 26 Jul 2004 18:19:29 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i6QGIro00176; Mon, 26 Jul 2004 11:18:53 -0500 (CDT) Date: Mon, 26 Jul 2004 11:26:46 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Martin Jambon cc: Matthieu Sozeau , Subject: Re: [Caml-list] Map + Set In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 41052EFC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 val:01 elt:01 elt:01 matthieu:01 matthieu:01 predicate:01 unsafe:01 int:01 arbitrary:02 jambon:02 wrote:03 object:03 redirect:95 implement:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 26 Jul 2004, Martin Jambon wrote: > > > > val find: (elt -> int) -> t -> elt > ^^^^^^^^^^^^ > This is a little unsafe, isn't it? What if you don't respect the ordering > of your set? Then the function throws Not_found when it shouldn't. If you already have the object you're looking for, why are you looking for it? Either that or you're using a set to really implement a map- use a map instead. > I think Brian and Matthieu are talking about 2 different things: > (1) Martin and Brian were talking of an O(log n) find just like mem. > (2) Matthieu and others are talking of a search using an > arbitrary predicate just like List.find, in O(n) steps. > What's the advantage of doing the search in O(n) time when you can do it in O(log n) time? A function that finds *all* elements that fit a certain criteria I can understand- but that's pretty easy to implement with fold. -- "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