Module:table/sparseConcat
Itsura
- This module lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
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