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 PAA13732; Fri, 24 Oct 2003 15:21:26 +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 PAA09982 for ; Fri, 24 Oct 2003 15:21:25 +0200 (MET DST) Received: from mwinf0601.wanadoo.fr (smtp6.wanadoo.fr [193.252.22.25]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9ODLO118626 for ; Fri, 24 Oct 2003 15:21:24 +0200 (MET DST) Received: from debian (ca-bordeaux-19-141.w80-8.abo.wanadoo.fr [80.8.91.141]) by mwinf0601.wanadoo.fr (SMTP Server) with ESMTP id 4504634001E3; Fri, 24 Oct 2003 15:21:24 +0200 (CEST) Received: from moi by debian with local (Exim 3.36 #1 (Debian)) id 1AD1tU-0003QS-00; Fri, 24 Oct 2003 15:22:20 +0200 To: Andrew Lenharth Cc: Dustin Sallings , caml-list@inria.fr Subject: Re: [Caml-list] newbie type problem References: <20031024005258.GA5049@davidb.org> <087CB9D7-05FB-11D8-B1A2-000393DC8AE4@spy.net> <20031024124958.GA15981@vilya.homelinux.net> From: Remi Vanicat Mail-Copy-To: never Date: Fri, 24 Oct 2003 15:22:20 +0200 In-Reply-To: <20031024124958.GA15981@vilya.homelinux.net> (Andrew Lenharth's message of "Fri, 24 Oct 2003 08:49:58 -0400") Message-ID: <87vfqercs3.dlv@wanadoo.fr> User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 newbie:01 hash:01 iterates:01 non-obvious:01 stringset:01 struct:01 stringset:01 caml:01 labri:01 u-bordeaux:01 writes:01 remi:01 remi:01 vanicat:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Andrew Lenharth writes: >> Yeah, but I still couldn't figure out how to make a Map, assuming >> that's what I really wanted in the first place. A hash table that >> iterates in key sorted order would make my app faster and reduce >> complexity. I want to see it actually work first, though. :) > > Yes, making a map is non-obvious. One first has to figure out the > module system, with no examples. Here is a hint: > > module StringSet = Set.Make(struct type t = string let compare x y = > compare x y end) > > then you can do things like > StringSet.mem n1 set;; > StringSet.union s1 s2;; > StringSet.add x StringSet.empty;; > > BTW: I am sure you can do the compare without the x y by > compare=compare. Yes you can. In recent caml you might even do : module StringSet = Set.Make (String) It work because in the stdlib's String module there is a type t equal to string, and a compare function. -- Rémi Vanicat ------------------- 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