Open main menu
Lua
CodeDiscussionEditHistoryLinksLink countNo test API Subpages:DocumentationTestsResultsSandboxLive code All modules

This template performs addition. For example, {{Sum|2|3}} creates 5.

Code

local p = {}

function p.main(frame)
	local parent = frame:getParent()
	local result = 0
	for key, value in ipairs(frame:getParent().args) do
		local _, _, number = string.find(value, "^%s*([-+%d%.eE]*)")
		result = result + (tonumber(number or 0) or 0)
	end
	return result or ""
end

return p