Skip to content

Commit

Permalink
add selectdim(A, 2, 3:4) example (#40456)
Browse files Browse the repository at this point in the history
This adds a `selectdim(A, 2, 3:4)` example to illustrate that several indices can be used (as this is not entirely clear in the text). Based on a suggestion in https://discourse.julialang.org/t/pick-rows-from-array-ndims-not-known-in-advance/59033/6
  • Loading branch information
PaulSoderlind authored Apr 19, 2021
1 parent d67f986 commit cfc45b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ julia> selectdim(A, 2, 3)
2-element view(::Matrix{Int64}, :, 3) with eltype Int64:
3
7
julia> selectdim(A, 2, 3:4)
2×2 view(::Matrix{Int64}, :, 3:4) with eltype Int64:
3 4
7 8
```
"""
@inline selectdim(A::AbstractArray, d::Integer, i) = _selectdim(A, d, i, _setindex(i, d, map(Slice, axes(A))...))
Expand Down

0 comments on commit cfc45b4

Please sign in to comment.