[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why no "continue" statement for loops?
- From: RLake@...
- Date: Tue, 24 Jun 2003 13:11:13 -0500
> Notice that you only get this behavior when you do tail calls. In Lua,
> this means "return f(...)". None of these apparently equivalent forms
> works:
> f(); return
> return x, f()
> return x or f()
> -- Roberto
But this one works :)
> function always(x) return function() return x end end
> function add(i, j) return (i == 0 and always(j) or add)(i - 1, j + 1)
end
> =add(1, 1000000)
1000001