function module.Sum(z,j)local I=0 if j then for j=1,j,1 do I=I+z[j>#z and#z or j]or 0 end else for z,j in pairs(z)do I=I+j end end return I end
--[[ @brief Sums all elements in a table.
     @param t A table of numbers.
     @return The total sum of all numbers in t.
--]]
function module.Sum(t, n)
	local sum = 0
	if n then
		for i = 1, n do
			sum = sum + t[i > #t and #t or i] or 0
		end
	else
		for i, v in pairs(t) do
			sum = sum + v
		end
	end
	return sum
end
