Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Library work multi-author

From ProleWiki, the proletarian encyclopedia
Revision as of 02:25, 16 October 2025 by Forte (talk | contribs) (Created page with "local p = {} function p.main(frame) local args = frame:getParent().args local items = {} for _, value in pairs(args) do if value ~= '' then -- ignores empty arguments table.insert(items, value) end end local count = #items if count == 0 then return "" -- returns nothing if empty elseif count == 1 then return items[1] -- just return the string input if alone elseif count ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local items = {}
    
    for _, value in pairs(args) do
        if value ~= '' then					-- ignores empty arguments
            table.insert(items, value)
        end
    end
    
    local count = #items
    
    if count == 0 then
        return ""			-- returns nothing if empty
    elseif count == 1 then
        return items[1]		-- just return the string input if alone
    elseif count == 2 then
        return items[1] .. " and " .. items[2]		-- returns "string1, string2, ... and last_string"
    else
        local last = table.remove(items)
        return table.concat(items, ", ") .. " and " .. last
    end
end

return p