Browse thread
[Caml-list] Map efficiency?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2003-11-04 (19:49) |
From: | Issac Trotts <ijtrotts@u...> |
Subject: | Re: [Caml-list] Map efficiency? |
> > 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