Jump to content

Module:table/sparseConcat

Wiktionary වෙතින්


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
"https://si.wiktionary.org/w/index.php?title=Module:table/sparseConcat&oldid=221349" වෙතින් සම්ප්‍රවේශනය කෙරිණි