From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 87038BC6B for ; Thu, 29 Nov 2007 09:40:28 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAADYJTkfAXQInh2dsb2JhbACPRQEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.23,228,1194217200"; d="scan'208";a="19800387" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Nov 2007 09:40:28 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lAT8eEuo018561 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 29 Nov 2007 09:40:28 +0100 From: luc.maranget@inria.fr (Luc Maranget) X-IronPort-AV: E=Sophos;i="4.23,228,1194217200"; d="scan'208";a="5051029" Received: from yquem.inria.fr ([128.93.8.37]) by mail1-relais-roc.national.inria.fr with ESMTP; 29 Nov 2007 09:40:28 +0100 Received: by yquem.inria.fr (Postfix, from userid 18041) id 01324BC6B; Thu, 29 Nov 2007 09:40:27 +0100 (CET) Date: Thu, 29 Nov 2007 09:40:27 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Help with simple ocaml memoization problem Message-ID: <20071129084027.GA16078@yquem.inria.fr> References: <005301c83260$15d1a850$017ca8c0@countertenor> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <005301c83260$15d1a850$017ca8c0@countertenor> User-Agent: Mutt/1.5.9i X-Miltered: at concorde with ID 474E7AEE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; maranget:01 maranget:01 ocaml:01 memoization:01 recursion:01 hashtbl:01 hashtbl:01 hash:01 mutable:01 non-mutable:01 peng:98 peng:98 knocking:98 wrote:01 wrote:01 > On 11/28/07, Evan Klitzke wrote: > > On 11/28/07, Peng Zang 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