We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
sum(::AbstractArray{Bool}; dims)
1 parent b8a686b commit be78f8bCopy full SHA for be78f8b
base/reduce.jl
@@ -523,9 +523,8 @@ julia> sum(1:20)
523
```
524
"""
525
sum(a; kw...) = sum(identity, a; kw...)
526
-sum(a::AbstractArray{Bool}; kw...) = count(a)
527
-# Note: It is OK to ignore `init` to `sum(::AbstractArray{Bool})`
528
-# because it is unspecified if the value of `init` is used or not.
+sum(a::AbstractArray{Bool}; init = nothing, kw...) =
+ init === nothing ? count(a; kw...) : reduce(add_sum, a; init = init, kw...)
529
530
## prod
531
0 commit comments