lua-users home
lua-l archive

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


On 7 June 2010 02:53, Javier Guerra Giraldez <javier@guerrag.com> wrote:
> On Sun, Jun 6, 2010 at 8:13 PM, T T <t34www@googlemail.com> wrote:
>> Which makes me wonder why #t is not specified in such a way to be
>> usefull for tables with holes too.
>
> can you suggest such a definition that also:
>
> - is useful for tables without holes
>
> - is quick to compute
>
> - has none or minimal memory requirements.
>
> - has none or minimal overhead on field assignment
>

The one given in the starting message of this thread seems to be the
most suitable from the "usefulness" POV:

"The length of a table t is defined to be the least non-negative
integer n such that t[n+1] is nil and t[m] is non-nil for any
positive integer m less than n+1."?

In other words #t would return size of the array part that is without holes.

Dunno, if this can be implemented to satisfy all of the above
requirements.  Perhaps others can comment on that.

Cheers,

Tomek