Re: The length function

new topic     » goto parent     » topic index » view thread      » older message » newer message
dr_can said...

The manual indicates that, for example,

length({{1,2}, {3,4}, {5,6}})   -- 3 

but what should

length({{}}) 

return?

The answer is 1, but why is it not 0?

Consider

sequence s1 = {} 
sequence s2 = {s1} 
 
? length(s2) -- returns 1 
? length(s1) -- returns 0 

Now, s2 is a sequence and s2[1] is s1. It is not empty in itself. The sequence s1 is empty however. Finally s2 is equivalent to

{{}} 

SD Pringle

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu