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 E143DBB81 for ; Mon, 6 Mar 2006 14:22:31 +0100 (CET) Received: from ptb-cgirelay01.plus.net (ptb-cgirelay01.plus.net [195.166.130.40]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k26DMU1E016749 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Mon, 6 Mar 2006 14:22:31 +0100 Message-Id: <200603061322.k26DMU1E016749@nez-perce.inria.fr> Received: from [212.159.6.58] (helo=ptn-atmail03.plus.net) by ptb-cgirelay01.plus.net with esmtp (Exim 4.34) id 1FGFfJ-0001Rw-2O; Mon, 06 Mar 2006 13:22:21 +0000 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: binary Mime-Version: 1.0 From: Jonathan Harrop To: caml-list@yquem.inria.fr, Michael Wohlwend Subject: Re: [Caml-list] recursive or loop Reply-To: jdh30@jdh30.plus.com X-Mailer: AtMail 4.01 X-Origin: 217.36.231.62 X-Uidl: 20060306130906452micha-1@fantasymailde Date: Mon, 06 Mar 2006 13:33:08 +0000 X-j-chkmail-Score: MSGID : 440C3796.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 440C3796.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 recursive:01 recursive:01 cheers:01 exception:01 exception:01 passing:01 argument:01 argument:01 algorithm:01 purely:02 functional:02 programming:03 programming:03 raise: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.5 required=5.0 tests=FROM_ENDS_IN_NUMS, MSGID_FROM_MTA_HEADER autolearn=disabled version=3.0.3 On Mon Mar 6 12:09 , Michael Wohlwend sent: >Is that true? No. >How do I jump out of a recursive algorithm and be able to >continue it at the same point? If you're doing purely functional programming then you'll be passing the state as an argument to the recursive function. So you just raise an exception that carries the current state, catch it outside and save the state. To restart you just load the state and pass it as an argument to the recursive function. If you're doing impure programming (i.e. with side-effects) then you do the same sort of thing but instead of carrying the state in the exception you have to capture it yourself (as you do in the looping version) and reset it yourself before you restart. There is probably no difference in difficulty. Cheers, Jon.