Skip to content
Permalink
Browse files

Docs and compat annotation for #29440 (colon constructor of Cartesian…

…Indices).
  • Loading branch information...
fredrikekre committed Nov 30, 2018
1 parent a04d13f commit 97036623312f284964f1e72d7df978f0b9743435
Showing with 20 additions and 0 deletions.
  1. +20 −0 base/multidimensional.jl
@@ -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)))

0 comments on commit 9703662

Please sign in to comment.
You can’t perform that action at this time.