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 MAA01119; Tue, 14 Oct 2003 12:44:52 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA18890 for ; Tue, 14 Oct 2003 12:44:51 +0200 (MET DST) Received: from indyio.rz.uni-saarland.de (indyio.rz.uni-saarland.de [134.96.7.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9EAio119185 for ; Tue, 14 Oct 2003 12:44:50 +0200 (MET DST) Received: from uni-sb.de (uni-sb.de [134.96.7.230]) by indyio.rz.uni-saarland.de (8.12.10/8.12.9) with ESMTP id h9EAioK730830472 for ; Tue, 14 Oct 2003 12:44:50 +0200 (CST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.252.31]) by uni-sb.de (8.12.10/2003073000) with ESMTP id h9EAinDx014814 for ; Tue, 14 Oct 2003 12:44:50 +0200 (CEST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.10/2003091100) with ESMTP id h9EAijgX028063 for ; Tue, 14 Oct 2003 12:44:49 +0200 (CEST) Received: from mail.st.cs.uni-sb.de (goscinny.cs.uni-sb.de [134.96.235.32]) by mail.cs.uni-sb.de (8.12.10/2003073000) with ESMTP id h9EAdtji011058 for ; Tue, 14 Oct 2003 12:39:55 +0200 (CEST) X-Authentication-Warning: email: Host goscinny.cs.uni-sb.de [134.96.235.32] claimed to be mail.st.cs.uni-sb.de Received: from jacobs.cs.uni-sb.de (jacobs.cs.uni-sb.de [134.96.235.135]) by mail.st.cs.uni-sb.de (Postfix) with ESMTP id 7331C34B1A0 for ; Tue, 14 Oct 2003 12:39:55 +0200 (CEST) Received: by jacobs.cs.uni-sb.de (Postfix, from userid 7528) id 5996997BF1; Tue, 14 Oct 2003 12:39:55 +0200 (CEST) Date: Tue, 14 Oct 2003 12:39:55 +0200 From: Christian Lindig To: Caml Mailing List Subject: [Caml-list] interface of sorted collections Message-ID: <20031014103955.GF20130@st> Mail-Followup-To: Christian Lindig , Caml Mailing List Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-No-Archive: yes X-URL: http://www.st.cs.uni-sb.de/~lindig/ User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lindig:01 lindig:01 uni-sb:01 ord:01 ord:01 prev:01 ocaml:01 sml:01 exists:01 modules:02 nested:02 module:03 interface:03 implement:05 seems:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I have noted that in sorted collections like the Map and Set modules (but also in SML/NJ's ORD_SET and ORD_MAP) it is impossible to find the previous or next element for a given element. This seems strange, given that the keys in these collections are sorted. In my particular application I like to store (nested) intervals in a map, sorted by their starting points. Given a point in an interval, I'd like to obtain it from a sorted collection. This requires either a find_less_equal function, that returns the key for an element if it exists or its predecessor, or a prev_key function, that returns a key's predecessor such that I can use the regular find afterwards. Is there a way to implement this in OCaml without making a copy of the Map module? -- Christian ------------------- 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