Closed
Description
Currently, the expression sum([])
leads to an error, since there is no way to know the intended neutral element ("zero") for an array of type Array{Any}
. I suggest to add a method to sum
(or to provide a new function sum0
) that accepts such a zero element. This would correspond to the existing method reduce(op, v0, itr)
.
The implementation would be straightforward:
function sum0(itr, v0)
isempty(itr) && return v0
sum(itr)
end
Equivalent methods should be added for prod
, minimum
, and maximum
as well.
Whether we can use the name sum
for this, or need to use a new name sum0
, depends on what methods currently exist for sum
and whether there would be a conflict.