[REBOL] Re: Tail end recursion
From: gedb01:y:ahoo at: 9-Oct-2003 16:52
Hi Max,
--- Maxim Olivier-Adlhoch <[maximo--meteorstudios--com]>
wrote: >
> so basically its like using recursion to do a loop?
>
> something: does [print "."]
>
> forever [
> do something
> ]
>
> is somewhat equivalent to?:
>
> something: does [
> something
> ]
>
> in F: func [x][x: x + 1 print x f x]
>
> but how does tail-end recursion stop?
>
> how does F ever end?
You stop by having a condition, and only calling again
if that condition is true.
So
while [keepGoing] [do something]
is equivalent to
something: func [keepgoing][if [keepgoing][do
something[keepgoing]]]