lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Axel Kittenberger wrote:
> > An alternative to the solution with tables is a vararg function:
> With what benefit? O(n) instead of O(log(n))?

First, why O(log(n))? Lua tables are hash tables, not balanced trees.

Second, the table-based solution is still O(n) because it creates a new
table with n elements each time. Anyway, Lua is not about micro

The benefit is compactness: you don't have to introduce any additional
local variables.

-- Gregory