Re: How can I STOP a cursed recursion?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> 
> Dan Moyer wrote:
> 
> <snip>
> 
> > Is there some way to just STOP a procedure, even if it has been working
> > recursivly??
> 
> Yes, it is.
> 
> > Or maybe recursion is supposed to be limited to FUNCTIONS?
> 
> No.
> 
> > procedure Help!()
> >   print(1,"help!")
> >   Help{}
> >   -- How can I stop!?
> > end procedure
> > 
> > Help!
> 
> }}}
<eucode>
> integer Count, NumTimes
> 
> procedure Help()
>    puts(1,"Help!\n")
>    Count += 1
>    if Count < NumTimes then
>       Help()
>    end if
> end procedure
> 
> Count = 0
> NumTimes = 3
> Help()
> </eucode>
{{{

> 
> The code above prints "Help!\n" three times. Often it is nice to use an
> additional non-recursive routine, which "wraps" the recursive routine, e.g.:
> 
> }}}
<eucode>
> integer Count, NumTimes
> 
> procedure Help()
>    puts(1,"Help!\n")
>    Count += 1
>    if Count < NumTimes then
>       Help()
>    end if
> end procedure
> 
> global procedure Call_Help(integer times)
>    -- This is the routine which is called by the user.
>    Count = 0
>    NumTimes = times        -- copy to local variable
>    Help()
> end procedure
> 
> Call_Help(3)
> </eucode>
{{{

> 
> Regards,
>    Juergen

Juergen,

Ok, that looks somewhat promising.  What I think you're saying is instead
of trying to STOP the recursion, only ask that it be done again from within
itself if some condition is met, ie, if it's not *finished* doing something.

I'll give that a try after I get some sleep.

Thanks!

Dan

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu