<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/3609cc72597a8a20efdcae335433c69f"
  from="Fred Smith &lt;fsmith@m...&gt;"
  author="Fred Smith"
  date="2003-11-07T15:27:37"
  subject="RE: [Caml-list] Efficient and canonical set representation?"
  prev="2003/11/0c6fb332cf336b39bf4442bf304e2f7b"
  next="2003/11/6ad97ddd5029978bbf694bfcf1b4b7ba"
  next-in-thread="2003/11/6ad97ddd5029978bbf694bfcf1b4b7ba"
  prev-thread="2003/11/810f9d2fb53a5d64dcf1e65d5252ea26"
  next-thread="2003/11/da696d358ae593a66f88c4f96053e5dc"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="RE: [Caml-list] Efficient and canonical set representation?">
<msg 
  url="2003/11/3609cc72597a8a20efdcae335433c69f"
  from="Fred Smith &lt;fsmith@m...&gt;"
  author="Fred Smith"
  date="2003-11-07T15:27:37"
  subject="RE: [Caml-list] Efficient and canonical set representation?">
<msg 
  url="2003/11/6ad97ddd5029978bbf694bfcf1b4b7ba"
  from="Samuel Lacas &lt;Samuel.Lacas@t...&gt;"
  author="Samuel Lacas"
  date="2003-11-07T15:44:31"
  subject="Re: [Caml-list] Efficient and canonical set representation?">
<msg 
  url="2003/11/9154764be7c671c358f3a9c80b98d866"
  from="Eray Ozkural &lt;exa@k...&gt;"
  author="Eray Ozkural"
  date="2003-11-08T16:50:48"
  subject="Re: [Caml-list] Efficient and canonical set representation?">
</msg>
</msg>
</msg>
</thread>

<contents>

I guess what you're looking for are sorted arrays:
  1) O(log n) lookup and insertion via binary search
  2) O(n) union and intersection are simple
  3) Equal sets are represented by structurally equivalent objects.

-Fred

&gt; -----Original Message-----
&gt; From: owner-caml-list@pauillac.inria.fr 
&gt; [mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of 
&gt; Harrison, John R
&gt; Sent: Friday, November 07, 2003 9:16 AM
&gt; To: erayo@cs.bilkent.edu.tr; caml-list@inria.fr
&gt; Cc: Harrison, John R
&gt; Subject: RE: [Caml-list] Efficient and canonical set representation?
&gt; 
&gt; 
&gt; | You basically want O(1) for set equality, I suppose.
&gt; 
&gt; Actually, no --- perhaps I should have made clearer what I 
&gt; *really* want. The efficiency of comparison wasn't my 
&gt; motivation, but rather elegance and aesthetics. And I meant 
&gt; "canonical" with respect to ordinary structural equality, not 
&gt; necessarily pointer equality, so the problem is potentially a 
&gt; bit easier than you might have thought.
&gt; 
&gt; I want to be able to treat an abstract type in a truly 
&gt; abstract way, and not worry about special-purpose equality 
&gt; relations on certain types. Otherwise it's an ugly mess 
&gt; dealing with complicated nestings like sets of pairs of lists of sets.
&gt; 
&gt; Now, I think the right solution, conceptually speaking, is to 
&gt; allow user-defined equality on abstract types. But as far as 
&gt; I know this cannot be done in OCaml, and I've never met much 
&gt; enthusiasm for the idea among the CAML or SML experts.
&gt; 
&gt; So a poor second best is to define abstract types in a canonical way, 
&gt; which was the starting-point of my question.
&gt; 
&gt; After your remarks and Brian's, I'm starting to wonder if it 
&gt; is possible at all to do what I want. Maybe I should be 
&gt; looking for an impossibility proof instead...
&gt; 
&gt; John.
&gt; 
&gt; -------------------
&gt; 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

-------------------
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

</contents>

</message>

