Модуль:ConcatArgs
Матеріал з Вікіпедії — вільної енциклопедії.
Зараз цей модуль не має відповідної документації. Якщо вам відомі призначення та засади використання цього модуля, будь ласка, напишіть хоча б коротеньку документацію. |
Дописувачі можуть експериментувати на підсторінках пісочниця (створити | дзеркало) та тести (створити) цього модуля. Підсторінки цієї сторінки. |
local p = {}
function table.slice(tbl, first, last, step)
local sliced = {}
for i = first or 1, last or #tbl, step or 1 do
sliced[#sliced+1] = tbl[i]
end
return sliced
end
p.slice = table.slice
local function count_args(table)
local nargs = 0
for num, _ in ipairs(table) do
nargs = num
end
return nargs
end
function p.ConcatArgs(frame)
local pargs = frame:getParent().args
local init = tonumber(frame.args["init"]) or frame.args["init"]
local slice = table.slice(
pargs,
tostring(frame.args["min"]),
count_args(pargs)
)
table.insert(slice, 1, pargs[init])
return table.concat(slice, "|")
end
return p
Text is available under the CC BY-SA 4.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.