lua-users home
lua-l archive

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


On Wed, Sep 17, 2014 at 8:47 AM,  <polyglot@openmailbox.org> wrote:
> On 2014-09-18 01:02, Coda Highland wrote:
>>
>>
>> This set of keys is {}, the empty set. It IS a member of the set of
>> sets of the form {1..n}, with n = 0.
>
>
> "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 (see §3.4.6)."
>
> Taking n = 0 seems pathological to me, even though 0 is indeed an integer.
> The main problem, however, is that any integer less than 1 produces the
> empty set. Try n = -42 with your for loop.
>
> So the length of the sequence wouldn't be uniquely defined. Obviously
> 0 makes the most sense, but the question is how one gets there from
> the manual.

I'm applying the strict rules of set logic here.  It's well-defined in
mathematics -- it's a DEGENERATE case, yes, but it's not an exception.
Would you complain that 1 isn't a power of 2 just because you can't
get there by multiplying a nonzero number of twos? It's the same
general concept.

n = -42 doesn't count because the definition specifically says
"positive numeric keys". A table containing { [-42] = "blah" } *is* a
sequence. The -42 isn't PART of the sequence, but the table is a
sequence. Likewise, { "a" = "blah" } is ALSO a sequence -- also a
zero-length one.

/s/ Adam