diff --git a/base/reducedim.jl b/base/reducedim.jl index c473049dd5fa0..ab62a39190926 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -321,8 +321,10 @@ julia> mapreduce(isodd, |, a, dims=1) """ mapreduce(f, op, A::AbstractArrayOrBroadcasted; dims=:, init=_InitialValue()) = _mapreduce_dim(f, op, init, A, dims) -mapreduce(f, op, A::AbstractArrayOrBroadcasted...; kw...) = - reduce(op, map(f, A...); kw...) +function mapreduce(f, op, A::AbstractArrayOrBroadcasted...; kw...) + get(kw, :dims, :) === (:) && return mapreduce(A -> f(A...), op, zip(A...); kw...) + return reduce(op, map(f, A...); kw...) +end _mapreduce_dim(f, op, nt, A::AbstractArrayOrBroadcasted, ::Colon) = mapfoldl_impl(f, op, nt, A)