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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL 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 D8AA2BC6B for ; Thu, 29 Nov 2007 16:59:51 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABpwTkfRVZK2mGdsb2JhbACPPwIBAQcEBCs X-IronPort-AV: E=Sophos;i="4.23,229,1194217200"; d="scan'208";a="19816503" Received: from wa-out-1112.google.com ([209.85.146.182]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Nov 2007 16:59:50 +0100 Received: by wa-out-1112.google.com with SMTP id k17so2447100waf for ; Thu, 29 Nov 2007 07:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date:user-agent:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; bh=6Z85MMRS4//efFDLLJWBlViQwsLv0ItlneeOexqHZzY=; b=aXsqQH2TDhZw8Cxq7AdHe04n4gcYo7bY6zmGsQvvjZuW6GV3bTcWbi/qh3MXHoRim3kNRClvTHLiXQymB1boGCr8wXaX+utsLhIo9xv45RH2pGWgqmpYED/YM9wzViCqlcrkxEyKFuJOed+UQxEUSd7J6YsEoaU+oZEx/Avew9o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:from:reply-to:to:subject:date:user-agent:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; b=rCh0nuZPGyO0MF/TGxkijkp96Xow7txGEVMra0QY90o6pWab/2oSMx0701ug3Bk7EAC3M9qzX/yQlbsiZk/ztqua8nFis2t3aSzZ/J+h1Pn87KYt7Z/OCUlFbOCx7fha4iQpe4VM2rreu2ZFuAArrRwoMcsfCGFWTZqdvBOYRHA= Received: by 10.110.47.10 with SMTP id u10mr158181tiu.1196351988621; Thu, 29 Nov 2007 07:59:48 -0800 (PST) Received: from tama-chan ( [24.99.180.210]) by mx.google.com with ESMTPS id h16sm2920556wxd.2007.11.29.07.59.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Nov 2007 07:59:47 -0800 (PST) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Help with simple ocaml memoization problem Date: Thu, 29 Nov 2007 10:59:42 -0500 User-Agent: KMail/1.9.7 References: <200711290053.15443.peng.zang@gmail.com> <200711290808.46180.jon@ffconsultancy.com> In-Reply-To: <200711290808.46180.jon@ffconsultancy.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711291059.45441.peng.zang@gmail.com> X-Spam: no; 0.00; ocaml:01 memoization:01 hash:01 recursion:01 recursive:01 compiler:01 ocaml:01 literals:01 peng:98 peng:98 ahhh:98 faithful:98 che:98 wrote:01 wrote:01 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ahhh.. that is helpful. Thanks Jon, Peng On Thursday 29 November 2007 03:08:45 am Jon Harrop wrote: > 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHTuHxfIRcEFL/JewRAhmoAKDCBN9QvQD5kxQATcOG9Ekj3YDkNQCeLiNl 1aGy4MJSYcMZfpcZY/D2chE= =WzAJ -----END PGP SIGNATURE-----