Browse thread
Help with simple ocaml memoization problem
[
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: | -- (:) |
| From: | luc.maranget@i... |
| Subject: | Re: [Caml-list] Help with simple ocaml memoization problem |
> On 11/28/07, Evan Klitzke <evan@yelp.com> wrote:
> > On 11/28/07, Peng Zang <peng.zang@gmail.com> wrote:
> > > I don't know how to increase the stack size off the top of my head, but
> > > in general you want to avoid recursion on the stack anyways. An easy
> > > way is to...
> >
> > Thanks Peng. This is much easier to grok than the code that I
> > originally wrote! One question that I have is what is the difference
> > between the Map and Hashtbl modules? From the documentation they look
> > very similar -- why did you use Hashtbl here rather than Map?
>
> Map is often slower (though hash tables potentially waste a lot of space and
> will be slower if you get lots of collisions, of course) and the functorial
> interface means that when "knocking" something together it's often tempting
> to use Hashtbl immediately just to save typing!
>
>
> David
There is another importtant difference, Hashtbl easily offers
a mutable data-structure, while Map offers a non-mutable (and thus
persistent) data structure.
As matter of fact, the OP code defined
let ann = ref IntMap.empty;;
^^
In that context, Hashtbl is also more natural.
--
Luc Maranget