lua-users home
lua-l archive

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

On 3 January 2011 11:01, Dirk Laurie <> wrote:
> On Mon, Jan 03, 2011 at 02:40:06AM +0200, Quae Quack wrote:
>> So... in lack of this magical site for working on common code, I
>> submit for consideration a suitable array implementation:
> Your code forces all indices to be numbers.  That is not necessary.
> It should force all integer keys to lie in a block 1 to #a with
> no holes, yes, but string keys are OK. They don't confuse the table
> library functions and  are quite useful.
> E.g. this line from a data file of finite integer sequences:
> entry{3,5,17,257,65537, note="all known Fermat primes", OEIS="A000215",
>    formula=function (n) return 2^(2^(n-1))+1 end}
> Dirk

That is not an array/list.
That is much more suited for another data format; most possibly the
native lua table.
The code I posted was for a list that accepts nil values.

PS, the code is for lua 5.2 only ==> __len needs to be respected.