[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-03-06 (13:22) |
From: | Jonathan Harrop <jdh30@j...> |
Subject: | Re: [Caml-list] recursive or loop |
On Mon Mar 6 12:09 , Michael Wohlwend <micha-1@fantasymail.de> 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.