# Is there a package for multidimensional ranges?

**URL:** https://discourse.julialang.org/t/is-there-a-package-for-multidimensional-ranges/98355
**Category:** General Usage
**Created:** [May 5, 2023, 12:35am UTC](https://discourse.julialang.org/t/is-there-a-package-for-multidimensional-ranges/98355 "2023-05-05T00:35:50Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [May 5, 2023, 5:01am UTC](https://discourse.julialang.org/t/is-there-a-package-for-multidimensional-ranges/98355/2 "2023-05-05T05:01:47Z")

</div>

Efficient rectangular grids: [RectiGrids.jl](https://gitlab.com/aplavin/RectiGrids.jl), some discussion:

> [@Regular grid](https://discourse.julialang.org/t/regular-grid/82371/2):
>
> Depends on what functionality you need from the grid. The most bare-bones rectangular grid is Iterators.product(1:10, 1:100): it can be iterated or mapped over, but isn’t even an array. More extensive grids can be created with the [RectiGrids.jl](https://gitlab.com/aplavin/RectiGrids.jl) package. They are arrays, and even more, KeyedArrays, providing convenient lookup methods. (disclaimer: I’m the package author)

Depending on what you need in the end, you may also use `map` on top of the grid:

```julia-auto
julia> using RectiGrids
julia> grid(1:3, 2:4)
2-dimensional KeyedArray(...) with keys:
↓ 3-element UnitRange{Int64}
→ 3-element UnitRange{Int64}
And data, 3×3 RectiGrids.RectiGridArr{...}:
      (2) (3) (4)
 (1) (1, 2) (1, 3) (1, 4)
 (2) (2, 2) (2, 3) (2, 4)
 (3) (3, 2) (3, 3) (3, 4)

# similar to rectangulardomain() from RootsAndPoles, but better:
# remains a multidimensional array, not a flat vector
julia> map(t -> complex(t...), grid(1:3, 2:4))
2-dimensional KeyedArray(...) with keys:
↓ 3-element UnitRange{Int64}
→ 3-element UnitRange{Int64}
And data, 3×3 Matrix{Complex{Int64}}:
      (2) (3) (4)
 (1) 1+2im 1+3im 1+4im
 (2) 2+2im 2+3im 2+4im
 (3) 3+2im 3+3im 3+4im

# mapview() instead of map() avoids materializing the whole array:
julia> using FlexiMaps
julia> mapview(t -> complex(t...), grid(1:3, 2:4))
3×3 FlexiMaps.MappedArray{...}:
 1+2im 1+3im 1+4im
 2+2im 2+3im 2+4im
 3+2im 3+3im 3+4im

```

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-package-for-multidimensional-ranges/98355)._
