[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: Lua 5.2 Length Operator and tables (bug?)**
**From**: Coda Highland <chighland@...>
**Date**: Tue, 17 Apr 2012 14:44:39 -0500

>
> We use the term sequence to denote a table where the set of all
> positive numeric keys is equal to {1..n} for some integer n, which
> is called the length of the sequence
>
> In this case, the set of all positive numeric keys is {1,3} — you can
> verify that by iterating through pairs() — which does not satisfy the
> definition.
>
Ah! I've been counter-nitpicked! Well played, sir. :)
I had interpreted that statement as saying "the table is a sequence if
it has, for some n (called the length), the set of positive numeric
keys in {1..n}" -- I had associated it together wrong.
Okay, yeah, then the only way to verify issequence is to either (1)
get the real size of the array part (which isn't exposed AFAIK) or (2)
iterate over pairs(t).
/s/ Adam