lua-users home
lua-l archive

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


On Apr 19, 2012, at 12:46 AM, Petite Abeille wrote:

>> To be more literal with the manual, one could reshuffle things a bit, something along these lines:
> 
> ooops… never mind… one will need to keep a state or something to check if there was at least one numerical key… oh, well…

Perhaps something like this:

local function is_seq( aTable )
  local isSeq = false

  for aKey in pairs( aTable ) do
    if type( aKey ) == 'number' and aKey > 0 and aKey == math.floor( aKey ) then
      if aTable[ math.max( aKey - 1, 1 ) ] == nil then
        return false
      else
        isSeq = true
      end
    end
  end

  return isSeq
end