[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Question about arrays...
- From: Coda Highland <chighland@...>
- Date: Sun, 9 Jun 2013 19:04:00 -0700
The important caveat here is that #t still returns a value that
satisfies the predicate listed earlier in the thread EVEN IF IT ISN'T
A SEQUENCE. For a non-sequence table, #t doesn't necessarily return
the LOWEST integer such that its predicate holds. This means that "for
i = 1,#t" and "for i,_ in ipairs(t)" can have different results.
/s/ Adam
On Sun, Jun 9, 2013 at 1:26 PM, Tim Hill <drtimhill@gmail.com> wrote:
> Yeah I was kind of assuming this was the definitive answer, which is good
> because it is what I assumed. TO my mind what this says is that the
> "sequence-ness" comes and goes depending upon the current state of the
> table:
>
> x = { [1]=1, [3]=3 } -- not an array (hole)
> x[2]=2 -- x is now an array (1..3)
> x.foo = "foo" -- Still an array, non positive numeric keys are ignored in
> def
> x[1] = nil -- No longer an array (doesn't start at one)
>
> --Tim
>
>
> On Jun 9, 2013, at 7:04 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>
> Not vague, but not labouring the point either. Let's say the Manual
> is mathematically precise on the subject.
>
> 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.
>
> Actually, the routines that depend on this property are not confused
> by positive numeric keys that can't be taken for integers, but the
> above is what it says.
>
>