From 28cf5fa7051e6e4254e55534219a156dc2c6824d Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 30 Nov 2018 18:07:48 +0100 Subject: [PATCH] Docs and compat annotation for #29440 (colon constructor of CartesianIndices). --- base/multidimensional.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 989139ef57837b..9d98c5776a3051 100644 --- a/base/multidimensional.jl +++ b/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)))