[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible bug with the length operator
- From: Mateusz Czaplinski <czapkofan@...>
- Date: Fri, 1 Apr 2011 09:33:39 +0200
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