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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 995E4BB81 for ; Wed, 8 Mar 2006 08:52:33 +0100 (CET) Received: from mxintern.schlund.de (mxintern.kundenserver.de [212.227.126.204]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k287qXb5011375 for ; Wed, 8 Mar 2006 08:52:33 +0100 Received: from [172.17.36.11] (helo=schluck.use.schlund.de) by mxintern.kundenserver.de with esmtp (Exim 4.34) id 1FGtTE-0004vy-Qi; Wed, 08 Mar 2006 08:52:32 +0100 From: Michael Wohlwend To: Alan Falloon Subject: Re: [Caml-list] recursive or loop Date: Wed, 8 Mar 2006 08:53:30 +0100 User-Agent: KMail/1.9.1 Cc: caml-list@yquem.inria.fr References: <200603061715.k26HF32w015203@nez-perce.inria.fr> <200603062222.49613.micha-1@fantasymail.de> <440DAEA3.1000204@synopsys.com> In-Reply-To: <440DAEA3.1000204@synopsys.com> X-Face: S)[vu%Bha1d&ej9GfwAq~7C}A,y[B.uS}+D6'hb~xPwsxymw$fnCOaMe<=?utf-8?q?*bnUajSBR=5Fm=3FR=0A=09?=@V3;iX8[A}z`.%pEQ1r7iZhN8#ktTCBQ}&mkx>=RH&l|l6\]NZI@ MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200603080853.30925.micha-1@fantasymail.de> X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Miltered: at nez-perce with ID 440E8D41.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 recursive:01 rec:01 iter:01 iter:01 cheers:01 2006:98 wrote:01 caml-list:01 alan:01 algorithm:01 data:02 element:03 element:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO,SPF_FAIL autolearn=disabled version=3.0.3 On Tuesday 07 March 2006 17:02, Alan Falloon wrote: > 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. I have indeed some problems converting it to a loop or to a tail-recusrsive function. It's of the form: let rec search result = if some_test then record_the result else begin iter (fun element -> iter (fun ...); search (element :: result); (* !!! *) iter (fun ...); ) data end ;; so the recursive call is in the middle and in an List.iter statment :-( cheers Michael