Module:table/isArray
පෙනුම
- මෙම module සතුව උපදෙස් උප පිටුවක් නොපවතියි. Please නිර්මාණය කරන්න.
- ප්රයෝජනවත් සබැඳි: root page • root page’s subpages • සබැඳි • transclusions • testcases • sandbox
local pairs = pairs
--[==[
Returns true if all keys in the table are consecutive integers starting from 1.]==]
return function(t)
-- pairs() is unordered, but can be assumed to return every key in `t`, so
-- if every integer key from 1 to n (the number of keys in `t`) is in use,
-- then all the keys in `t` form an integer range from 1 to n, making `t`
-- a contiguous array.
local i = 0
for _ in pairs(t) do
i = i + 1
if t[i] == nil then
return false
end
end
return true
end