local getArgs = require('Module:Arguments').getArgslocal p =
function p.main(frame) local args = getArgs(frame) return p._main(args)end
-- Main function to calculate average changefunction p._main(args) local class = args.class local omitop = args.omitop local params =
-- Filter out nil values and convert to numbers local values = for _, v in ipairs(params) do v = tonumber(v) if v then table.insert(values, v) end end
-- Dash (blank) if fewer than 2 valid values if #values < 2 then return '—' end
-- Calculate changes local changes = for i = 1, #values - 1 do if class
-- Calculate average change local sum = 0 for _, change in ipairs(changes) do sum = sum + change end
local avgChange = sum / #changes local formattedChange = string.format("%.2f", avgChange)
-- Omit the operator if specified if omitop
return formattedChangeend
return p