Modul:table/sparseIpairs
Tampaian
Dokumentasi untuk modul ini dapat dibuat di Modul:table/sparseIpairs/doc
-- Imported from enwiktionary
-- Source: https://en.wiktionary.org/wiki/Module:table/sparseIpairs
-- License: CC BY-SA
local table_num_keys_module = "Module:table/numKeys"
local function num_keys(...)
num_keys = require(table_num_keys_module)
return num_keys(...)
end
--[==[
An iterator which works like `ipairs`, but which works for sparse arrays.]==]
return function(t)
local keys, i = num_keys(t), 0
return function()
i = i + 1
local k = keys[i]
if k ~= nil then
return k, t[k]
end
end
end