Skip to content

Commit

Permalink
docstring comment about eachslice
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Feb 9, 2022
1 parent 16aca24 commit 4ce40cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4ce40cc

Please sign in to comment.