Re: How can I STOP a cursed recursion?
- Posted by Al Getz <Xaxo at aol.com> Jun 20, 2006
- 533 views
Hi there Dan, As others have mentioned, all you need to do is have a 'test' within your procedure to make sure there is a true exit at some point in the execution...i think this will illustrate: constant Data={1,2,3,4,5,0} integer k k=0 procedure Help() k+=1 if Data[k]=0 then ?k return else Help() end if end procedure Help() The main idea is that the procedure checks some aspect of the data it's working on and makes a decision to either return or call another Help(). This of course means that that particular aspect of the data must be changing while in the procedure so that the procedure can make an intelligent decision on it's own, without outside help. The following routine would NOT work because it's data never changes: constant Data={1,2,3,4,5,0} integer k k=1 procedure Help() if Data[k]!=0 then Help() else return end if end procedure Help() Just a guess, but your routine may want to test to see if the next piece of data is a sequence or an atom, and take the appropriate actions. BTW, it's true that after a number of recurcive calls the code will 'unravel' by executing a whole bunch of 'return' statements, or perhaps just 'end procedure' a whole bunch of times, but only if it's designed right in the first place Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's" From "Black Knight": "I can live with losing the good fight, but i can not live without fighting it". "Well on second thought, maybe not."