From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 435DBBB81 for ; Tue, 7 Mar 2006 17:02:48 +0100 (CET) Received: from kiruna.synopsys.com (us01smtp2.synopsys.com [198.182.44.80]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k27G2lhi016277 for ; Tue, 7 Mar 2006 17:02:47 +0100 Received: from mother.synopsys.com (mother.synopsys.com [146.225.100.171]) by kiruna.synopsys.com (Postfix) with ESMTP id A24ADF56D; Tue, 7 Mar 2006 08:05:22 -0800 (PST) Received: from US01WEBRH2.internal.synopsys.com (localhost [127.0.0.1]) by mother.synopsys.com (8.9.1/8.9.1) with ESMTP id IAA06183; Tue, 7 Mar 2006 08:02:46 -0800 (PST) Received: from ca05osmium.internal.synopsys.com ([10.44.8.226]) by US01WEBRH2.internal.synopsys.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 7 Mar 2006 08:02:45 -0800 Received: from [10.44.9.158] ([10.44.9.158]) by ca05osmium.internal.synopsys.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 7 Mar 2006 11:02:43 -0500 Message-ID: <440DAEA3.1000204@synopsys.com> Date: Tue, 07 Mar 2006 11:02:43 -0500 From: Alan Falloon User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Michael Wohlwend Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] recursive or loop References: <200603061715.k26HF32w015203@nez-perce.inria.fr> <200603061925.35321.micha-1@fantasymail.de> <20060306192526.GA29897@fork.recoil.org> <200603062222.49613.micha-1@fantasymail.de> In-Reply-To: <200603062222.49613.micha-1@fantasymail.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Mar 2006 16:02:43.0586 (UTC) FILETIME=[918ABE20:01C64200] X-Miltered: at concorde with ID 440DAEA7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 anil:01 recursive:01 ocaml:01 stack:01 2006:98 wrote:01 wrote:01 caml-list:01 imperative:01 alan:01 alan:01 algorithm:01 converting:05 converting:05 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Michael Wohlwend wrote: > On Monday 06 March 2006 20:25, Anil Madhavapeddy wrote: > >> To answer your original question, I wouldn't get too religious about >> recursive vs imperative styles; OCaml lets you choose and mix them, >> so pick the one that gets the job done for you and move on to the >> finer things in life :-) >> > > yop, that's true; it's just that in my case the recursive version is pretty > nice :-) > If you can easily convert it to a tail-recursive function, then you don't need to record any stack info, and its as easy as recording the current arguments like Jon Harrop pointed out. Converting a recursive function to a tail-recursive one is as hard as converting it to an interative algorithm: the two forms are pretty much the same. -- Alan Falloon