[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: documentation style - 2nd/3rd person tense for function comments
- From: andreas graeper <agraeper@...>
- Date: Tue, 27 Mar 2012 21:29:53 +0000
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.
2012/3/27, Roberto Ierusalimschy <roberto@inf.puc-rio.br>:
>> l={-1,nil,1,nil,3,nil,5}
>> #l => 7
>>
>> 7 is no n, so that l[n] is not nil, but l[n+1] is.
>
>> l={-1,nil,1,nil,3,nil,5}
>> print(#l)
> 7
>> n = 7
>> print(l[n], l[n + 1])
> 5 nil
>
>
> -- Roberto
>
>