မော်ဂျူး:table/sparseConcat
အပွိုင်အငုဲင်ꩻ
Documentation for this module may be created at မော်ဂျူး:table/sparseConcat/doc
local table_sparse_ipairs_module = "Module:table/sparseIpairs"
local concat = table.concat
local function sparse_ipairs(...)
sparse_ipairs = require(table_sparse_ipairs_module)
return sparse_ipairs(...)
end
--[==[
Concatenates all values in a table that are indexed by a number, in order.
* {sparseConcat{ a, nil, c, d }} => {"acd"}
* {sparseConcat{ nil, b, c, d }} => {"bcd"}]==]
return function(t, sep, i, j)
local list, k = {}, 0
for _, v in sparse_ipairs(t) do
k = k + 1
list[k] = v
end
return concat(list, sep, i, j)
end