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 UAA29437; Tue, 4 Nov 2003 20:49:13 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA28971 for ; Tue, 4 Nov 2003 20:49:11 +0100 (MET) Received: from pop9.ucdavis.edu (pop9.ucdavis.edu [169.237.105.19]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hA4JnA105051 for ; Tue, 4 Nov 2003 20:49:10 +0100 (MET) Received: from beech (beech.ucdavis.edu [128.120.141.134]) by pop9.ucdavis.edu (8.12.9/8.12.9/it-std-5.0.2) with ESMTP id hA4Jn8EV001632 for ; Tue, 4 Nov 2003 11:49:08 -0800 (PST) Received: from ijtrotts by beech with local (Exim 3.36 #1 (Debian)) id 1AH7Jm-0005XM-00 for ; Tue, 04 Nov 2003 11:58:22 -0800 Date: Tue, 4 Nov 2003 11:58:22 -0800 From: Issac Trotts To: caml-list@inria.fr Subject: Re: [Caml-list] Map efficiency? Message-ID: <20031104195822.GA20928@ucdavis.edu> Reply-To: ijtrotts@ucdavis.edu References: <16295.27991.49290.47666@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16295.27991.49290.47666@gargle.gargle.HOWL> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; issac:01 trotts:01 ijtrotts:01 caml-list:01 beginners:01 generic:01 map's:01 ord:01 pervasives:01 generic:01 redwood:99 issac:01 val:01 abstr:01 foo:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Also, is there a particular reason Map is so, um, inaccessible to > > beginners? Hashtbl's generic interface is much more inviting than > > Map's functorial-only interface, especially to those not terribly > > familiar with the module system. > > Just copy the body of Map.Make and replace Ord.compare by > Pervasives.compare and you'll get a polymorphic version of Map, as > easy to use as Hashtbl's generic interface. > > But I agree: it's a shame ocaml does not provide it. Thanks for the idea. Here is the modified code: http://redwood.ucdavis.edu/~issac/map2.tar.gz # #load "map2.cmo";; # let map = ref Map2.empty;; val map : ('_a, '_b) Map2.t ref = {contents = } # map := Map2.add "foo" 23 !map;; - : unit = () # map := Map2.add "bar" 42 !map;; - : unit = () # Map2.iter (fun key v -> Printf.printf "%s : %i\n" key v) !map;; bar : 42 foo : 23 - : unit = () -- Issac Trotts ------------------- 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