Module:Wd: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1,638:
assert(p[f], 'The function "' .. f .. '" does not exist')
-- positional parameters;
args = {}
-- shift them one index forward
for i, v in ipairs(frame.args) do
if i > 1 then
args[i-1] = v
end
end
end
-- named parameters;
-- simply copy these
for i, v in pairs(frame.args) do
-- pairs() also iterates over the positional parameters,
-- so ignore those since they have been added by the last loop already
if not args[i] then
args[i] = {}v
end
end
-- last loop added the last positional parameter under its previous key again,
-- so just remove it (it has been copied to #frame.args-1 already)
args[#frame.args] = nil
frame.args = args