From 4ce40cc06f87a4faf4bddca19d05552005ed60b2 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 15 Dec 2021 11:07:05 -0500 Subject: [PATCH] docstring comment about eachslice --- base/abstractarray.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 923b3b29a48b26..80fd51b4be4ed0 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -2770,6 +2770,11 @@ julia> map(g, eachslice(A, dims=2)) julia> mapslices(sum, A; dims=(1,3)) == sum(A; dims=(1,3)) true ``` + +Notice that in `eachslice(A; dims=2)`, the specified dimension is the +one *without* a colon in the slice. This is `view(A,:,i,:)`, whereas +`mapslices(f, A; dims=(1,3))` uses `A[:,i,:]`. The function `f` may mutate +values in the slice without affecting `A`. """ function mapslices(f, A::AbstractArray; dims) isempty(dims) && return map(f, A)