lua-users home
lua-l archive

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


> ok, i am tired.

> i started with {1,nil,3,nil,5} and thought of l[-1]=<something != nil>
> 
> l = {1,nil,3,nil,5}  -- #l is 5, feels good
> l[-1] = 0
> print(#l) tells 1
> 
> -1 is no numeric index, but string it isn't, too
> l[-1] != l['-1']
> 
> can i calculate with paper and pencil what length such an table will have
> a) if there is no non-integer index than n maximal, such that l[n]<>nil
> b) if there is at least one non-integer index, than n minimal, such
> that l[n]<>nil and l[n]==nil
> 
> if l starts with gap l={nil,2,3} as in a) #l is 3
> when l[-1]=1 than #l=0 (n=0 but l[0] is nil, l[1]=nil too)
> 
> new b) at least one non-integer index (0 inclusive), than 0<=n
> minimal, such that l[n+1]=nil
> 
> probably i am not the first, wondering.
> 
> 

#l is defined only for sequences
Sequence is an array starting with index 1 and having no nils inside
#l may return any nonsense value for non-sequence tables

--Egor