<?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/10/f70a630abcb73995f40868e5b4aedd5d"
  from="Andrew Lenharth &lt;andrewl@d...&gt;"
  author="Andrew Lenharth"
  date="2003-10-24T12:50:08"
  subject="Re: [Caml-list] newbie type problem"
  prev="2003/10/ef7ea5a38d2bceb896eb567f1eff1764"
  next="2003/10/4046091fba633875058f2de17f0ff1e7"
  prev-in-thread="2003/10/a7c47b1fe652cbc379e868c63cd6fa6f"
  next-in-thread="2003/10/4046091fba633875058f2de17f0ff1e7"
  prev-thread="2003/10/e7f6c0d5605db8954852475f246f1109"
  next-thread="2003/10/ef7ea5a38d2bceb896eb567f1eff1764"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] newbie type problem">
<msg 
  url="2003/10/2e8a6962baf66f1c24c5f132e0e4d98a"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-10-24T06:11:43"
  subject="[Caml-list] newbie type problem">
<msg 
  url="2003/10/1ec46ca647143db0b89bf64b3fe444da"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-10-24T06:32:48"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/9e4d0c48d7066d16614195d454ef1c0d"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-10-24T06:54:14"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/082653152d78e76edce7de62398f8c1f"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-10-24T07:53:03"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/a7c47b1fe652cbc379e868c63cd6fa6f"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-10-24T08:21:36"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/f70a630abcb73995f40868e5b4aedd5d"
  from="Andrew Lenharth &lt;andrewl@d...&gt;"
  author="Andrew Lenharth"
  date="2003-10-24T12:50:08"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/4046091fba633875058f2de17f0ff1e7"
  from="Remi Vanicat &lt;vanicat@l...&gt;"
  author="Remi Vanicat"
  date="2003-10-24T13:21:26"
  subject="Re: [Caml-list] newbie type problem">
</msg>
</msg>
<msg 
  url="2003/10/1271d8cb3491b0027667093a335ee94e"
  from="Florian Hars &lt;hars@b...&gt;"
  author="Florian Hars"
  date="2003-10-29T07:23:31"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/f070014a1ae9dad3251d6334d87f1555"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-10-29T08:03:55"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/669fd0c0dff2b0a039406b7cb928916d"
  from="Florian Hars &lt;hars@b...&gt;"
  author="Florian Hars"
  date="2003-10-29T16:27:29"
  subject="Re: [Caml-list] newbie type problem">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/bc22b36f43b4dd5f6d7af456fd0801fc"
  from="Hendrik Tews &lt;tews@t...&gt;"
  author="Hendrik Tews"
  date="2003-10-24T09:25:16"
  subject="Re: [Caml-list] newbie type problem">
<msg 
  url="2003/10/196dea4817e90f7281ee0ccc73dd15a7"
  from="Dustin Sallings &lt;dustin@s...&gt;"
  author="Dustin Sallings"
  date="2003-10-24T16:23:13"
  subject="Re: [Caml-list] newbie type problem">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
&gt; 	Yeah, but I still couldn't figure out how to make a Map, assuming 
&gt; that's what I really wanted in the first place.  A hash table that 
&gt; iterates in key sorted order would make my app faster and reduce 
&gt; 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.

A bit about what is going on.  Set is a parameratized module which you 
must narrow to what you want.  So you use the Make function to return a 
module with the types you want.  They you can use this module in your 
code.

Good examples of this are few and far between.

Andrew Lenharth

-- 
"The reasonable man adapts himself to the world; the unreasonable 
one persists in trying to adapt the world to 
himself. Therefore all progress depends on the unreasonable man."
-- George Bernard Shaw

No matter how cynical you become, it's never enough to keep up.
-- Lily Tomlin

Fools ignore complexity; pragmatists suffer it; experts avoid it; 
geniuses remove it.
-- A. Perlis

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

