Skip to content

Commit

Permalink
Docs and compat annotation for #29440 (colon constructor of Cartesian…
Browse files Browse the repository at this point in the history
…Indices).
  • Loading branch information
fredrikekre committed Dec 1, 2018
1 parent ebc7931 commit 0f0a600
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ module IteratorsMD

CartesianIndices(A::AbstractArray) = CartesianIndices(axes(A))

"""
(:)(I::CartesianIndex, J::CartesianIndex)
Construct [`CartesianIndices`](@ref) from two `CartesianIndex`.
!!! compat "Julia 1.1"
This method requires at least Julia 1.1.
# Examples
```jldoctest
julia> I = CartesianIndex(2,1);
julia> J = CartesianIndex(3,3);
julia> I:J
2×3 CartesianIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
CartesianIndex(2, 1) CartesianIndex(2, 2) CartesianIndex(2, 3)
CartesianIndex(3, 1) CartesianIndex(3, 2) CartesianIndex(3, 3)
```
"""
(:)(I::CartesianIndex{N}, J::CartesianIndex{N}) where N =
CartesianIndices(map((i,j) -> i:j, Tuple(I), Tuple(J)))

Expand Down

0 comments on commit 0f0a600

Please sign in to comment.