Modul:Math: Unterschied zwischen den Versionen
keine Bearbeitungszusammenfassung
(get #expr without a frame, don't make unnecessary wrappers, and lazily initialise dependent modules, per protected edit request by User:Jackmcbarn) |
Keine Bearbeitungszusammenfassung |
||
Zeile 249: | Zeile 249: | ||
if min_value then | if min_value then | ||
return min_value | return min_value | ||
end | |||
end | |||
--[[ | |||
sum | |||
Finds the sum | |||
Usage: | |||
{{#invoke:Math| sum | value1 | value2 | ... }} | |||
OR | |||
{{#invoke:Math| sum }} | |||
Note, any values that do not evaluate to numbers are ignored. | |||
]] | |||
function wrap.sum(args) | |||
return p._sum(unpackNumberArgs(args)) | |||
end | |||
function p._sum(...) | |||
local function getSum(a, b) | |||
return a + b | |||
end | |||
local sum, count = applyFuncToArgs(getSum, ...) | |||
if not sum then | |||
return 0 | |||
else | |||
return sum | |||
end | end | ||
end | end |