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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id CE73CBC6B for ; Thu, 29 Nov 2007 09:17:56 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AigcAEoETkfUnw7XYmdsb2JhbACCOY0CFQQGEBk X-IronPort-AV: E=Sophos;i="4.23,228,1194217200"; d="scan'208";a="4723163" Received: from fhw-relay07.plus.net ([212.159.14.215]) by mail2-smtp-roc.national.inria.fr with ESMTP; 29 Nov 2007 09:17:56 +0100 Received: from [80.229.56.224] (helo=beast.local) by fhw-relay07.plus.net with esmtp (Exim) id 1Ixeap-0005Xi-Sj for caml-list@yquem.inria.fr; Thu, 29 Nov 2007 08:17:56 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Help with simple ocaml memoization problem Date: Thu, 29 Nov 2007 08:08:45 +0000 User-Agent: KMail/1.9.5 References: <200711290053.15443.peng.zang@gmail.com> In-Reply-To: <200711290053.15443.peng.zang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711290808.46180.jon@ffconsultancy.com> X-Spam: no; 0.00; ocaml:01 memoization:01 recursion:01 recursive:01 compiler:01 ocaml:01 literals:01 peng:98 faithful:98 frog:98 wrote:01 stack:01 stack:01 caml-list:01 tail:01 On Thursday 29 November 2007 05:53, 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 simply make the function tail recursive so the compiler can optimized it > into a loop for you. Here's a pretty faithful replication of your python > code. Note I use Int64 instead of BigInt as I'm running OCaml 3.09.3. > ... > let l1 = Int64.of_int 1;; > let l2 = Int64.of_int 2;; > let l3 = Int64.of_int 3;; OCaml has int64 literals built-in: # 3L;; - : int64 = 3L -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e