[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Little fun with vararg
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 5 Aug 2014 09:55:40 -0300
> I don't know. This
>
> x = 5
> function F(...)
> return F(x,...)
> end
>
> print(F())
>
> is taking an awful long time to fail.
I believe this is O(n^2), as each new call copies all accumulated
arguments. Change your function to this and you will see the
slowdown:
local x = 0
function F(...)
x = x + 1
print(x)
return F(x,...)
end
print(F())
(The stack limit is 100 000...)
-- Roberto