Module:table/append
Appearance
- This module lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
local select = select local function append(n, i, t, t_len, item, ...) local k = 0 while true do k = k + 1 local v = item[k] if v ~= nil then t_len = t_len + 1 t[t_len] = v elseif i == n then return t else return append(n, i + 1, t, t_len, ...) end end end --[==[ Appends any number of lists together as a new list.]==] return function(...) local n, t = select("#", ...), {} return n == 0 and t or append(n, 1, t, 0, ...) end