caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Issac Trotts <ijtrotts@ucdavis.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Map efficiency?
Date: Tue, 4 Nov 2003 11:58:22 -0800	[thread overview]
Message-ID: <20031104195822.GA20928@ucdavis.edu> (raw)
In-Reply-To: <16295.27991.49290.47666@gargle.gargle.HOWL>

>  > 	Also, is there a particular reason Map is so, um, inaccessible to 
>  > beginners?  Hashtbl's generic interface is much more inviting than 
>  > Map's functorial-only interface, especially to those not terribly 
>  > familiar with the module system.
> 
> Just   copy  the  body   of  Map.Make   and  replace   Ord.compare  by
> Pervasives.compare  and you'll get  a polymorphic  version of  Map, as
> easy to use as Hashtbl's generic interface.
> 
> But I agree: it's a shame ocaml does not provide it.

Thanks for the idea.  Here is the modified code:

  http://redwood.ucdavis.edu/~issac/map2.tar.gz

# #load "map2.cmo";;
# let map = ref Map2.empty;;
val map : ('_a, '_b) Map2.t ref = {contents = <abstr>}
# map := Map2.add "foo" 23 !map;;
- : unit = ()
# map := Map2.add "bar" 42 !map;;
- : unit = ()
# Map2.iter (fun key v -> Printf.printf "%s : %i\n" key v) !map;;
bar : 42
foo : 23
- : unit = ()

-- 
Issac Trotts

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


  parent reply	other threads:[~2003-11-04 19:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-04  7:59 Dustin Sallings
2003-11-04  9:11 ` Jean-Christophe Filliatre
2003-11-04 10:00   ` Richard Jones
2003-11-04 19:58   ` Issac Trotts [this message]
2003-11-04  9:39 ` Christian Lindig
2003-11-04 18:14   ` Alex Baretta
2003-11-05  1:09     ` Nicolas Cannasse
2003-11-07  8:27     ` Jean-Christophe Filliatre
2003-11-07 11:39       ` Why are functors better? (Re: [Caml-list] Map efficiency?) Yaron M. Minsky
2003-11-07 14:02         ` Michael Hicks
2003-11-07 14:08         ` Fernando Alegre
2003-11-07 14:49       ` [Caml-list] Map efficiency? Florian Hars
2003-11-04 19:37   ` Dustin Sallings

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=20031104195822.GA20928@ucdavis.edu \
    --to=ijtrotts@ucdavis.edu \
    --cc=caml-list@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).