caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@bpr.best.vwh.net>
To: "Vincent Barichard <Vincent Barichard"
	<Vincent.Barichard@info.univ-angers.fr>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] Polymorphic Set
Date: Wed, 19 Dec 2001 19:47:23 +0000 (GMT)	[thread overview]
Message-ID: <Pine.BSF.4.40.0112191941400.23293-100000@bpr.best.vwh.net> (raw)
In-Reply-To: <15392.58778.897378.738285@helios.info-ua>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1490 bytes --]

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 =
  sig
    type 'a t
    val compare: 'a t -> 'a t -> int
  end

module type S =
  sig
    type 'a elt
    type 'a t
    ...
  end

module Make(Ord: OrderedType) =
  struct
    type 'a elt = 'a Ord.t
    type 'a t = Empty | Node of 'a t * 'a elt * 'a t * int
    ...
   end

I hope that helps.

-- Brian

On Wed, 19 Dec 2001, Vincent Barichard <Vincent Barichard wrote:

>
> 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.
>
> 	module MySet = Set.Make (struct
> 		type t = ('a * float)
> 		let compare = function (_, valx) -> function (_, valy) ->
> 			if valx < valy then 1
> 			else if valx > valy then -1
> 			else 0
> 	end)
>
> Anybody has an idea on how to do ?
>
> Thanks for your help,
>
> Vincent
>
> --
> Vincent Barichard
> Métaheuristiques et Optimisation Combinatoire
> Faculté des Sciences d'Angers
> Tel : 02 41 73 52 06
> -------------------
> 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
>
-------------------
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


      reply	other threads:[~2001-12-20 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-19 19:08 Vincent Barichard <Vincent Barichard
2001-12-19 19:47 ` Brian Rogoff [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.BSF.4.40.0112191941400.23293-100000@bpr.best.vwh.net \
    --to=bpr@bpr.best.vwh.net \
    --cc=Vincent.Barichard@info.univ-angers.fr \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).