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 NAA07098; Thu, 20 Dec 2001 13:27:48 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA07633 for caml-list@pauillac.inria.fr; Thu, 20 Dec 2001 13:27:47 +0100 (MET) 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 UAA29121 for ; Wed, 19 Dec 2001 20:47:25 +0100 (MET) Received: from sj1-3-4-9.securesites.net (sj1-3-4-9.securesites.net [192.220.127.202]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBJJlO107274 for ; Wed, 19 Dec 2001 20:47:25 +0100 (MET) Received: (qmail 34985 invoked by uid 16863); 19 Dec 2001 19:47:23 -0000 Received: from unknown (HELO localhost) ([192.220.65.223]) (envelope-sender ) by 192.220.65.223 (qmail-ldap-1.03) with SMTP for ; 19 Dec 2001 19:47:23 -0000 Date: Wed, 19 Dec 2001 19:47:23 +0000 (GMT) From: Brian Rogoff To: "Vincent Barichard cc: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Polymorphic Set In-Reply-To: <15392.58778.897378.738285@helios.info-ua> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, You can copy the source code of Set and make a new Polyset module. I'll start, and the rest should be clear module type OrderedType =3D sig type 'a t val compare: 'a t -> 'a t -> int end module type S =3D sig type 'a elt type 'a t ... end module Make(Ord: OrderedType) =3D struct type 'a elt =3D 'a Ord.t type 'a t =3D Empty | Node of 'a t * 'a elt * 'a t * int ... end I hope that helps. -- Brian On Wed, 19 Dec 2001, Vincent Barichard > Hi, > > Is there a way in OCAML to create polymorphic Set (as for List) ? > I've tried the following code, but ocaml don't like. > > =09module MySet =3D Set.Make (struct > =09=09type t =3D ('a * float) > =09=09let compare =3D function (_, valx) -> function (_, valy) -> > =09=09=09if valx < valy then 1 > =09=09=09else if valx > valy then -1 > =09=09=09else 0 > =09end) > > Anybody has an idea on how to do ? > > Thanks for your help, > > Vincent > > -- > Vincent Barichard > M=E9taheuristiques et Optimisation Combinatoire > Facult=E9 des Sciences d'Angers > Tel : 02 41 73 52 06 > ------------------- > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.f= r/FAQ/ > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.in= ria.fr > ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr