Skip to content
Prev 310477 / 398506 Next

Problem with recursion

On Sat, Nov 10, 2012 at 7:41 AM, Haszun <crazystef13 at tlen.pl> wrote:
Just a hint: do you need a while condition? If so, might a return()
help you out? If not, what's the cleanest way to eliminate it? Note
that R has the convention that the final value in the function is the
one returned, but that constructs like this can trip you up:

x <- 5
while(x > 0) x <- x - 1
print(.Last.value)

Cheers,
Michael