মডিউল:parameters/lite/list numbers
অবয়ব
< মডিউল:parameters | lite
এই মডিউলের জন্য মডিউল:parameters/lite/list numbers/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
local function clean(x) return x and #x > 0 and x or nil end
-- implements a numbered list parameter, somewhat
return function (args, base, allow_holes, allow_empty)
local results = {}
local maximum_index = 0
base = base - 1
for index, value in pairs(args) do
if type(index) == "number" and index > base then
value = mw.text.trim(value)
if not allow_empty then value = clean(value) end
index = index - base
results[index] = value
maximum_index = math.max(maximum_index, index)
end
end
if maximum_index > 0 then
if not allow_holes then
local i = 1
local j = 1
while i <= maximum_index do
if results[i] then
results[j] = results[i]
if j < i then results[i] = nil end
j = j + 1
end
i = i + 1
end
else
results.maxindex = maximum_index
end
end
return results
end