lua-users home
lua-l archive

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


> Petite Abeille wrote:
>
> local function is_seq( aTable )

I do it this way:

function is_seq(aTable)
   local count=0
   local nmax=-1
   for k in pairs(aTable) do
      n=tonumber(k)
      if n and n%1==0 and n>0 then
          count=count+1; nmax=math.max(nmax,n)
      end
    end
    return nmax==count
end

BTW, why does the definition of a proper sequence exclude {}?
The table functions and length operator work properly in that case too.