lua-users home
lua-l archive

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


On Thu, Mar 31, 2011 at 5:28 PM, Arvid Enbom <arvid_divran@hotmail.com> wrote:
> According to the Lua reference manual, the length operator (#) is supposed
> to return the highest consecutive numerical index. This means the above code
> SHOULD return 2, because 3 is nil.

What all the others said (generally, "don't use #t when t is table
with holes"), plus: that's a known pitfall, but unfortunately noone
has found any smart enough solution for that yet. Where "smart" does
among others mean "effective", which I think reads like "O(1) in time
and memory"; although a thought now occured to me that something
better than O(n) might also be interesting?

greetings
Mateusz Czapliński