## [Broadcast and vectorization](#Broadcast-and-vectorization)
`Broadcast.DefaultArrayStyle{N}()` is a [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle) indicating that an object behaves as an `N`-dimensional array for broadcasting. Specifically, `DefaultArrayStyle` is used for any `AbstractArray` type that hasn't defined a specialized style, and in the absence of overrides from other `broadcast` arguments the resulting output type is `Array`. When there are multiple inputs to `broadcast`, `DefaultArrayStyle` "loses" to any other [`Broadcast.ArrayStyle`](#Base.Broadcast.ArrayStyle).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L89-L96)
```julia
Broadcast.broadcastable(x)
```
Return either `x` or an object like `x` such that it supports [`axes`](#Base.axes-Tuple%7BAny%7D), indexing, and its type supports [`ndims`](#Base.ndims).
If `x` supports iteration, the returned value should have the same `axes` and indexing behaviors as [`collect(x)`](../collections/#Base.collect-Tuple%7BAny%7D).
If `x` is not an `AbstractArray` but it supports `axes`, indexing, and its type supports `ndims`, then `broadcastable(::typeof(x))` may be implemented to just return itself. Further, if `x` defines its own [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle), then it must define its `broadcastable` method to return itself for the custom style to have any effect.
**Examples**


## [Broadcast and vectorization](#Broadcast-and-vectorization)
```julia-repl
julia> Broadcast.broadcastable([1,2,3]) # like `identity` since arrays already support axes and indexing
3-element Vector{Int64}:
 1
 2
 3

julia> Broadcast.broadcastable(Int) # Types don't support axes, indexing, or iteration but are commonly used as scalars
Base.RefValue{Type{Int64}}(Int64)

julia> Broadcast.broadcastable("hello") # Strings break convention of matching iteration and act like a scalar instead
Base.RefValue{String}("hello")
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L680-L707)
```julia
combine_axes(As...) -> Tuple
```
Determine the result axes for broadcasting across all values in `As`.
```julia-repl
julia> Broadcast.combine_axes([1], [1 2; 3 4; 5 6])
(Base.OneTo(3), Base.OneTo(2))

julia> Broadcast.combine_axes(1, 1, 1)
()
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L483-L495)
```julia
combine_styles(cs...) -> BroadcastStyle
```
Decides which `BroadcastStyle` to use for any number of value arguments. Uses [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle) to get the style for each argument, and uses [`result_style`](#Base.Broadcast.result_style) to combine styles.
**Examples**
```julia-repl
julia> Broadcast.combine_styles([1], [1 2; 3 4])
Base.Broadcast.DefaultArrayStyle{2}()
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L409-L422)


## [Broadcast and vectorization](#Broadcast-and-vectorization)
```julia
result_style(s1::BroadcastStyle[, s2::BroadcastStyle]) -> BroadcastStyle
```
Takes one or two `BroadcastStyle`s and combines them using [`BroadcastStyle`](#Base.Broadcast.BroadcastStyle) to determine a common `BroadcastStyle`.
**Examples**
```julia-repl
julia> Broadcast.result_style(Broadcast.DefaultArrayStyle{0}(), Broadcast.DefaultArrayStyle{3}())
Base.Broadcast.DefaultArrayStyle{3}()

julia> Broadcast.result_style(Broadcast.Unknown(), Broadcast.DefaultArrayStyle{1}())
Base.Broadcast.DefaultArrayStyle{1}()
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/broadcast.jl#L434-L449)


## [Indexing and assignment](#Indexing-and-assignment)
```julia
getindex(A, inds...)
```
Return a subset of array `A` as selected by the indices `inds`.
Each index may be any [supported index type](../../manual/arrays/#man-supported-index-types), such as an [`Integer`](../numbers/#Core.Integer), [`CartesianIndex`](#Base.IteratorsMD.CartesianIndex), [range](../collections/#Base.AbstractRange), or [array](../../manual/arrays/#man-multi-dim-arrays) of supported indices. A [:](#Base.Colon) may be used to select all elements along a specific dimension, and a boolean array (e.g. an `Array{Bool}` or a [`BitArray`](#Base.BitArray)) may be used to filter for elements where the corresponding index is `true`.
When `inds` selects multiple elements, this function returns a newly allocated array. To index multiple elements without making a copy, use [`view`](#Base.view) instead.
See the manual section on [array indexing](../../manual/arrays/#man-array-indexing) for details.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> getindex(A, 1)
1

julia> getindex(A, [2, 1])
2-element Vector{Int64}:
 3
 1

julia> getindex(A, 2:4)
3-element Vector{Int64}:
 3
 2
 4

julia> getindex(A, 2, 1)
3

julia> getindex(A, CartesianIndex(2, 1))
3

julia> getindex(A, :, 2)
2-element Vector{Int64}:
 2
 4

julia> getindex(A, 2, :)
2-element Vector{Int64}:
 3
 4

julia> getindex(A, A .> 2)
2-element Vector{Int64}:
 3
 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1251-L1308)


## [Indexing and assignment](#Indexing-and-assignment)
```julia
setindex!(A, X, inds...)
A[inds...] = X
```
Store values from array `X` within some subset of `A` as specified by `inds`. The syntax `A[inds...] = X` is equivalent to `(setindex!(A, X, inds...); X)`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> A = zeros(2,2);

julia> setindex!(A, [10, 20], [1, 2]);

julia> A[[3, 4]] = [30, 40];

julia> A
2×2 Matrix{Float64}:
 10.0  30.0
 20.0  40.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1387-L1409)
```julia
nextind(A, i)
```
Return the index after `i` in `A`. The returned index is often equivalent to `i + 1` for an integer `i`. This function can be useful for generic code.
The returned index might be out of bounds. Consider using [`checkbounds`](#Base.checkbounds).
See also: [`prevind`](#Base.prevind).
**Examples**
```julia-repl
julia> x = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> nextind(x, 1) # valid result
2

julia> nextind(x, 4) # invalid result
5

julia> nextind(x, CartesianIndex(1, 1)) # valid result
CartesianIndex(2, 1)

julia> nextind(x, CartesianIndex(2, 2)) # invalid result
CartesianIndex(1, 3)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L110-L141)
```julia
prevind(A, i)
```
Return the index before `i` in `A`. The returned index is often equivalent to `i - 1` for an integer `i`. This function can be useful for generic code.


## [Indexing and assignment](#Indexing-and-assignment)
The returned index might be out of bounds. Consider using [`checkbounds`](#Base.checkbounds).
See also: [`nextind`](#Base.nextind).
**Examples**
```julia-repl
julia> x = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> prevind(x, 4) # valid result
3

julia> prevind(x, 1) # invalid result
0

julia> prevind(x, CartesianIndex(2, 2)) # valid result
CartesianIndex(1, 2)

julia> prevind(x, CartesianIndex(1, 1)) # invalid result
CartesianIndex(2, 0)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L76-L107)
```julia
copyto!(dest, Rdest::CartesianIndices, src, Rsrc::CartesianIndices) -> dest
```
Copy the block of `src` in the range of `Rsrc` to the block of `dest` in the range of `Rdest`. The sizes of the two regions must match.
**Examples**
```julia-repl
julia> A = zeros(5, 5);

julia> B = [1 2; 3 4];

julia> Ainds = CartesianIndices((2:3, 2:3));

julia> Binds = CartesianIndices(B);

julia> copyto!(A, Ainds, B, Binds)
5×5 Matrix{Float64}:
 0.0  0.0  0.0  0.0  0.0
 0.0  1.0  2.0  0.0  0.0
 0.0  3.0  4.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L1177-L1201)
```julia
copy!(dst, src) -> dst
```


## [Indexing and assignment](#Indexing-and-assignment)
In-place [`copy`](../base/#Base.copy) of `src` into `dst`, discarding any pre-existing elements in `dst`. If `dst` and `src` are of the same type, `dst == src` should hold after the call. If `dst` and `src` are multidimensional arrays, they must have equal [`axes`](#Base.axes-Tuple%7BAny%7D).
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also [`copyto!`](../c/#Base.copyto!).
This method requires at least Julia 1.1. In Julia 1.0 this method is available from the `Future` standard library as `Future.copy!`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L893-L909)
```julia
isassigned(array, i) -> Bool
```
Test whether the given array has a value associated with index `i`. Return `false` if the index is out of bounds, or has an undefined reference.
**Examples**
```julia-repl
julia> isassigned(rand(3, 3), 5)
true

julia> isassigned(rand(3, 3), 3 * 3 + 1)
false

julia> mutable struct Foo end

julia> v = similar(rand(3), Foo)
3-element Vector{Foo}:
 #undef
 #undef
 #undef

julia> isassigned(v, 1)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L963-L988)
```julia
Colon()
```
Colons (:) are used to signify indexing entire objects or dimensions at once.


## [Indexing and assignment](#Indexing-and-assignment)
Very few operations are defined on Colons directly; instead they are converted by [`to_indices`](#Base.to_indices) to an internal vector type (`Base.Slice`) to represent the collection of indices they span before being used.
The singleton instance of `Colon` is also a function used to construct ranges; see [`:`](../math/#Base.::).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L997-L1008)
```julia
CartesianIndex(i, j, k...)   -> I
CartesianIndex((i, j, k...)) -> I
```
Create a multidimensional index `I`, which can be used for indexing a multidimensional array `A`. In particular, `A[I]` is equivalent to `A[i,j,k...]`. One can freely mix integer and `CartesianIndex` indices; for example, `A[Ipre, i, Ipost]` (where `Ipre` and `Ipost` are `CartesianIndex` indices and `i` is an `Int`) can be a useful expression when writing algorithms that work along a single dimension of an array of arbitrary dimensionality.
A `CartesianIndex` is sometimes produced by [`eachindex`](#Base.eachindex), and always when iterating with an explicit [`CartesianIndices`](#Base.IteratorsMD.CartesianIndices).
An `I::CartesianIndex` is treated as a "scalar" (not a container) for `broadcast`. In order to iterate over the components of a `CartesianIndex`, convert it to a tuple with `Tuple(I)`.
**Examples**


## [Indexing and assignment](#Indexing-and-assignment)
```julia-repl
julia> A = reshape(Vector(1:16), (2, 2, 2, 2))
2×2×2×2 Array{Int64, 4}:
[:, :, 1, 1] =
 1  3
 2  4

[:, :, 2, 1] =
 5  7
 6  8

[:, :, 1, 2] =
  9  11
 10  12

[:, :, 2, 2] =
 13  15
 14  16

julia> A[CartesianIndex((1, 1, 1, 1))]
1

julia> A[CartesianIndex((1, 1, 1, 2))]
9

julia> A[CartesianIndex((1, 1, 2, 1))]
5
```
Using a `CartesianIndex` as a "scalar" for `broadcast` requires Julia 1.10; in previous releases, use `Ref(I)`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L19-L72)
```julia
CartesianIndices(sz::Dims) -> R
CartesianIndices((istart:[istep:]istop, jstart:[jstep:]jstop, ...)) -> R
```
Define a region `R` spanning a multidimensional rectangular range of integer indices. These are most commonly encountered in the context of iteration, where `for I in R ... end` will return [`CartesianIndex`](#Base.IteratorsMD.CartesianIndex) indices `I` equivalent to the nested loops
```julia
for j = jstart:jstep:jstop
    for i = istart:istep:istop
        ...
    end
end
```
Consequently these can be useful for writing algorithms that work in arbitrary dimensions.
```julia
CartesianIndices(A::AbstractArray) -> R
```
As a convenience, constructing a `CartesianIndices` from an array makes a range of its indices.
The step range method `CartesianIndices((istart:istep:istop, jstart:[jstep:]jstop, ...))` requires at least Julia 1.6.
**Examples**


## [Indexing and assignment](#Indexing-and-assignment)
```julia-repl
julia> foreach(println, CartesianIndices((2, 2, 2)))
CartesianIndex(1, 1, 1)
CartesianIndex(2, 1, 1)
CartesianIndex(1, 2, 1)
CartesianIndex(2, 2, 1)
CartesianIndex(1, 1, 2)
CartesianIndex(2, 1, 2)
CartesianIndex(1, 2, 2)
CartesianIndex(2, 2, 2)

julia> CartesianIndices(fill(1, (2,3)))
CartesianIndices((2, 3))
```
**Conversion between linear and cartesian indices**
Linear index to cartesian index conversion exploits the fact that a `CartesianIndices` is an `AbstractArray` and can be indexed linearly:
```julia-repl
julia> cartesian = CartesianIndices((1:3, 1:2))
CartesianIndices((1:3, 1:2))

julia> cartesian[4]
CartesianIndex(1, 2)

julia> cartesian = CartesianIndices((1:2:5, 1:2))
CartesianIndices((1:2:5, 1:2))

julia> cartesian[2, 2]
CartesianIndex(3, 2)
```
**Broadcasting**
`CartesianIndices` support broadcasting arithmetic (+ and -) with a `CartesianIndex`.
Broadcasting of CartesianIndices requires at least Julia 1.1.
```julia-repl
julia> CIs = CartesianIndices((2:3, 5:6))
CartesianIndices((2:3, 5:6))

julia> CI = CartesianIndex(3, 4)
CartesianIndex(3, 4)

julia> CIs .+ CI
CartesianIndices((5:6, 9:10))
```
For cartesian to linear index conversion, see [`LinearIndices`](#Base.LinearIndices).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L185-L266)
```julia
Dims{N}
```
An `NTuple` of `N` `Int`s used to represent the dimensions of an [`AbstractArray`](#Core.AbstractArray).


## [Indexing and assignment](#Indexing-and-assignment)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L3-L8)
```julia
LinearIndices(A::AbstractArray)
```
Return a `LinearIndices` array with the same shape and [`axes`](#Base.axes-Tuple%7BAny%7D) as `A`, holding the linear index of each entry in `A`. Indexing this array with cartesian indices allows mapping them to linear indices.
For arrays with conventional indexing (indices start at 1), or any multidimensional array, linear indices range from 1 to `length(A)`. However, for `AbstractVector`s linear indices are `axes(A, 1)`, and therefore do not start at 1 for vectors with unconventional indexing.
Calling this function is the "safe" way to write algorithms that exploit linear indexing.
**Examples**
```julia-repl
julia> A = fill(1, (5,6,7));

julia> b = LinearIndices(A);

julia> extrema(b)
(1, 210)
```
```julia
LinearIndices(inds::CartesianIndices) -> R
LinearIndices(sz::Dims) -> R
LinearIndices((istart:istop, jstart:jstop, ...)) -> R
```
Return a `LinearIndices` array with the specified shape or [`axes`](#Base.axes-Tuple%7BAny%7D).
**Examples**
The main purpose of this constructor is intuitive conversion from cartesian to linear indexing:
```julia-repl
julia> linear = LinearIndices((1:3, 1:2))
3×2 LinearIndices{2, Tuple{UnitRange{Int64}, UnitRange{Int64}}}:
 1  4
 2  5
 3  6

julia> linear[1,2]
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L436-L482)
```julia
to_indices(A, I::Tuple)
```


## [Indexing and assignment](#Indexing-and-assignment)
Convert the tuple `I` to a tuple of indices for use in indexing into array `A`.
The returned tuple must only contain either `Int`s or `AbstractArray`s of scalar indices that are supported by array `A`. It will error upon encountering a novel index type that it does not know how to process.
For simple index types, it defers to the unexported `Base.to_index(A, i)` to process each index `i`. While this internal function is not intended to be called directly, `Base.to_index` may be extended by custom array or index types to provide custom indexing behaviors.
More complicated index types may require more context about the dimension into which they index. To support those cases, `to_indices(A, I)` calls `to_indices(A, axes(A), I)`, which then recursively walks through both the given tuple of indices and the dimensional indices of `A` in tandem. As such, not all index types are guaranteed to propagate to `Base.to_index`.
**Examples**
```julia-repl
julia> A = zeros(1,2,3,4);

julia> to_indices(A, (1,1,2,2))
(1, 1, 2, 2)

julia> to_indices(A, (1,1,2,20)) # no bounds checking
(1, 1, 2, 20)

julia> to_indices(A, (CartesianIndex((1,)), 2, CartesianIndex((3,4)))) # exotic index
(1, 2, 3, 4)

julia> to_indices(A, ([1,1], 1:2, 3, 4))
([1, 1], 1:2, 3, 4)

julia> to_indices(A, (1,2)) # no shape checking
(1, 2)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L319-L358)
```julia
checkbounds(Bool, A, I...)
```


## [Indexing and assignment](#Indexing-and-assignment)
Return `true` if the specified indices `I` are in bounds for the given array `A`. Subtypes of `AbstractArray` should specialize this method if they need to provide custom bounds checking behaviors; however, in many cases one can rely on `A`'s indices and [`checkindex`](#Base.checkindex).
See also [`checkindex`](#Base.checkindex).
**Examples**
```julia-repl
julia> A = rand(3, 3);

julia> checkbounds(Bool, A, 2)
true

julia> checkbounds(Bool, A, 3, 4)
false

julia> checkbounds(Bool, A, 1:3)
true

julia> checkbounds(Bool, A, 1:3, 2:4)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L652-L678)
```julia
checkbounds(A, I...)
```
Throw an error if the specified indices `I` are not in bounds for the given array `A`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L692-L696)
```julia
checkindex(Bool, inds::AbstractUnitRange, index)
```
Return `true` if the given `index` is within the bounds of `inds`. Custom types that would like to behave as indices for all arrays can extend this method in order to provide a specialized bounds checking implementation.
See also [`checkbounds`](#Base.checkbounds).
**Examples**
```julia-repl
julia> checkindex(Bool, 1:20, 8)
true

julia> checkindex(Bool, 1:20, 21)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L732-L750)
```julia
elsize(type)
```


## [Indexing and assignment](#Indexing-and-assignment)
Compute the memory stride in bytes between consecutive elements of [`eltype`](../collections/#Base.eltype) stored inside the given `type`, if the array elements are stored densely with a uniform linear stride.
**Examples**
```julia-repl
julia> Base.elsize(rand(Float32, 10))
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L244-L256)


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
A “view” is a data structure that acts like an array (it is a subtype of `AbstractArray`), but the underlying data is actually part of another array.
For example, if `x` is an array and `v = @view x[1:10]`, then `v` acts like a 10-element array, but its data is actually accessing the first 10 elements of `x`. Writing to a view, e.g. `v[3] = 2`, writes directly to the underlying array `x` (in this case modifying `x[3]`).
Slicing operations like `x[1:10]` create a copy by default in Julia. `@view x[1:10]` changes it to make a view. The `@views` macro can be used on a whole block of code (e.g. `@views function foo() .... end` or `@views begin ... end`) to change all the slicing operations in that block to use views. Sometimes making a copy of the data is faster and sometimes using a view is faster, as described in the [performance tips](../../manual/performance-tips/#man-performance-views).
```julia
view(A, inds...)
```


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
Like [`getindex`](../collections/#Base.getindex), but returns a lightweight array that lazily references (or is effectively a *view* into) the parent array `A` at the given index or indices `inds` instead of eagerly extracting elements or constructing a copied subset. Calling [`getindex`](../collections/#Base.getindex) or [`setindex!`](../collections/#Base.setindex!) on the returned value (often a [`SubArray`](#Base.SubArray)) computes the indices to access or modify the parent array on the fly. The behavior is undefined if the shape of the parent array is changed after `view` is called because there is no bound check for the parent array; e.g., it may cause a segmentation fault.
Some immutable parent arrays (like ranges) may choose to simply recompute a new array in some circumstances instead of returning a `SubArray` if doing so is efficient and provides compatible semantics.
In Julia 1.6 or later, `view` can be called on an `AbstractString`, returning a `SubString`.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> b = view(A, :, 1)
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
 1
 3

julia> fill!(b, 0)
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
 0
 0

julia> A # Note A has changed even though we modified b
2×2 Matrix{Int64}:
 0  2
 0  4

julia> view(2:5, 2:3) # returns a range as type is immutable
3:4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/subarray.jl#L165-L210)


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
```julia
@view A[inds...]
```
Transform the indexing expression `A[inds...]` into the equivalent [`view`](#Base.view) call.
This can only be applied directly to a single indexing expression and is particularly helpful for expressions that include the special `begin` or `end` indexing syntaxes like `A[begin, 2:end-1]` (as those are not supported by the normal [`view`](#Base.view) function).
Note that `@view` cannot be used as the target of a regular assignment (e.g., `@view(A[1, 2:end]) = ...`), nor would the un-decorated [indexed assignment](../../manual/arrays/#man-indexed-assignment) (`A[1, 2:end] = ...`) or broadcasted indexed assignment (`A[1, 2:end] .= ...`) make a copy. It can be useful, however, for *updating* broadcasted assignments like `@view(A[1, 2:end]) .+= 1` because this is a simple syntax for `@view(A[1, 2:end]) .= @view(A[1, 2:end]) + 1`, and the indexing expression on the right-hand side would otherwise make a copy without the `@view`.
See also [`@views`](#Base.@views) to switch an entire block of code to use views for non-scalar indexing.
Using `begin` in an indexing expression to refer to the first index requires at least Julia 1.5.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> b = @view A[:, 1]
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
 1
 3

julia> fill!(b, 0)
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
 0
 0

julia> A
2×2 Matrix{Int64}:
 0  2
 0  4
```


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/views.jl#L77-L124)
```julia
@views expression
```
Convert every array-slicing operation in the given expression (which may be a `begin`/`end` block, loop, function, etc.) to return a view. Scalar indices, non-array types, and explicit [`getindex`](../collections/#Base.getindex) calls (as opposed to `array[...]`) are unaffected.
Similarly, `@views` converts string slices into [`SubString`](../strings/#Base.SubString) views.
The `@views` macro only affects `array[...]` expressions that appear explicitly in the given `expression`, not array slicing that occurs in functions called by that code.
Using `begin` in an indexing expression to refer to the first index was implemented in Julia 1.4, but was only supported by `@views` starting in Julia 1.5.
**Examples**
```julia-repl
julia> A = zeros(3, 3);

julia> @views for row in 1:3
           b = A[row, :] # b is a view, not a copy
           b .= row      # assign every element to the row index
       end

julia> A
3×3 Matrix{Float64}:
 1.0  1.0  1.0
 2.0  2.0  2.0
 3.0  3.0  3.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/views.jl#L211-L246)
```julia
parent(A)
```


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
Return the underlying parent object of the view. This parent of objects of types `SubArray`, `SubString`, `ReshapedArray` or `LinearAlgebra.Transpose` is what was passed as an argument to `view`, `reshape`, `transpose`, etc. during object creation. If the input is not a wrapped object, return the input itself. If the input is wrapped multiple times, only the outermost wrapper will be removed.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> V = view(A, 1:2, :)
2×2 view(::Matrix{Int64}, 1:2, :) with eltype Int64:
 1  2
 3  4

julia> parent(V)
2×2 Matrix{Int64}:
 1  2
 3  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1454-L1479)
```julia
parentindices(A)
```
Return the indices in the [`parent`](#Base.parent) which correspond to the view `A`.
**Examples**
```julia-repl
julia> A = [1 2; 3 4];

julia> V = view(A, 1, :)
2-element view(::Matrix{Int64}, 1, :) with eltype Int64:
 1
 2

julia> parentindices(V)
(1, Base.Slice(Base.OneTo(2)))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/subarray.jl#L83-L100)
```julia
selectdim(A, d::Integer, i)
```
Return a view of all the data of `A` where the index for dimension `d` equals `i`.
Equivalent to `view(A,:,:,...,i,:,:,...)` where `i` is in position `d`.
See also: [`eachslice`](#Base.eachslice).
**Examples**


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
```julia-repl
julia> A = [1 2 3 4; 5 6 7 8]
2×4 Matrix{Int64}:
 1  2  3  4
 5  6  7  8

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
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L226-L252)
```julia
reinterpret(::Type{Out}, x::In)
```
Change the type-interpretation of the binary data in the isbits value `x` to that of the isbits type `Out`. The size (ignoring padding) of `Out` has to be the same as that of the type of `x`. For example, `reinterpret(Float32, UInt32(7))` interprets the 4 bytes corresponding to `UInt32(7)` as a [`Float32`](../numbers/#Core.Float32). Note that `reinterpret(In, reinterpret(Out, x)) === x`
```julia-repl
julia> reinterpret(Float32, UInt32(7))
1.0f-44

julia> reinterpret(NTuple{2, UInt8}, 0x1234)
(0x34, 0x12)

julia> reinterpret(UInt16, (0x34, 0x12))
0x1234

julia> reinterpret(Tuple{UInt16, UInt8}, (0x01, 0x0203))
(0x0301, 0x02)
```
The treatment of padding differs from reinterpret(::DataType, ::AbstractArray).
Use caution if some combinations of bits in `Out` are not considered valid and would otherwise be prevented by the type's constructors and methods. Unexpected behavior may result without additional validation.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L694-L727)


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
```julia
reinterpret(T::DataType, A::AbstractArray)
```
Construct a view of the array with the same binary data as the given array, but with `T` as element type.
This function also works on "lazy" array whose elements are not computed until they are explicitly retrieved. For instance, `reinterpret` on the range `1:6` works similarly as on the dense vector `collect(1:6)`:
```julia-repl
julia> reinterpret(Float32, UInt32[1 2 3 4 5])
1×5 reinterpret(Float32, ::Matrix{UInt32}):
 1.0f-45  3.0f-45  4.0f-45  6.0f-45  7.0f-45

julia> reinterpret(Complex{Int}, 1:6)
3-element reinterpret(Complex{Int64}, ::UnitRange{Int64}):
 1 + 2im
 3 + 4im
 5 + 6im
```
If the location of padding bits does not line up between `T` and `eltype(A)`, the resulting array will be read-only or write-only, to prevent invalid bits from being written to or read from, respectively.
```julia-repl
julia> a = reinterpret(Tuple{UInt8, UInt32}, UInt32[1, 2])
1-element reinterpret(Tuple{UInt8, UInt32}, ::Vector{UInt32}):
 (0x01, 0x00000002)

julia> a[1] = 3
ERROR: Padding of type Tuple{UInt8, UInt32} is not compatible with type UInt32.

julia> b = reinterpret(UInt32, Tuple{UInt8, UInt32}[(0x01, 0x00000002)]); # showing will error

julia> b[1]
ERROR: Padding of type UInt32 is not compatible with type Tuple{UInt8, UInt32}.
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reinterpretarray.jl#L30-L67)
```julia
reinterpret(reshape, T, A::AbstractArray{S}) -> B
```


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
Change the type-interpretation of `A` while consuming or adding a "channel dimension."
If `sizeof(T) = n*sizeof(S)` for `n>1`, `A`'s first dimension must be of size `n` and `B` lacks `A`'s first dimension. Conversely, if `sizeof(S) = n*sizeof(T)` for `n>1`, `B` gets a new first dimension of size `n`. The dimensionality is unchanged if `sizeof(T) == sizeof(S)`.
This method requires at least Julia 1.6.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> reinterpret(reshape, Complex{Int}, A)    # the result is a vector
2-element reinterpret(reshape, Complex{Int64}, ::Matrix{Int64}) with eltype Complex{Int64}:
 1 + 3im
 2 + 4im

julia> a = [(1,2,3), (4,5,6)]
2-element Vector{Tuple{Int64, Int64, Int64}}:
 (1, 2, 3)
 (4, 5, 6)

julia> reinterpret(reshape, Int, a)             # the result is a matrix
3×2 reinterpret(reshape, Int64, ::Vector{Tuple{Int64, Int64, Int64}}) with eltype Int64:
 1  4
 2  5
 3  6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reinterpretarray.jl#L142-L178)
```julia
reshape(A, dims...) -> AbstractArray
reshape(A, dims) -> AbstractArray
```
Return an array with the same data as `A`, but with different dimension sizes or number of dimensions. The two arrays share the same underlying data, so that the result is mutable if and only if `A` is mutable, and setting elements of one alters the values of the other.


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
The new dimensions may be specified either as a list of arguments or as a shape tuple. At most one dimension may be specified with a `:`, in which case its length is computed such that its product with all the specified dimensions is equal to the length of the original array `A`. The total number of elements must not change.
**Examples**
```julia-repl
julia> A = Vector(1:16)
16-element Vector{Int64}:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16

julia> reshape(A, (4, 4))
4×4 Matrix{Int64}:
 1  5   9  13
 2  6  10  14
 3  7  11  15
 4  8  12  16

julia> reshape(A, 2, :)
2×8 Matrix{Int64}:
 1  3  5  7   9  11  13  15
 2  4  6  8  10  12  14  16

julia> reshape(1:6, 2, 3)
2×3 reshape(::UnitRange{Int64}, 2, 3) with eltype Int64:
 1  3  5
 2  4  6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reshapedarray.jl#L64-L117)
```julia
dropdims(A; dims)
```
Return an array with the same data as `A`, but with the dimensions specified by `dims` removed. `size(A,d)` must equal 1 for every `d` in `dims`, and repeated dimensions or numbers outside `1:ndims(A)` are forbidden.
The result shares the same underlying data as `A`, such that the result is mutable if and only if `A` is mutable, and setting elements of one alters the values of the other.
See also: [`reshape`](#Base.reshape), [`vec`](#Base.vec).
**Examples**


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
```julia-repl
julia> a = reshape(Vector(1:4),(2,2,1,1))
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
 1  3
 2  4

julia> b = dropdims(a; dims=3)
2×2×1 Array{Int64, 3}:
[:, :, 1] =
 1  3
 2  4

julia> b[1,1,1] = 5; a
2×2×1×1 Array{Int64, 4}:
[:, :, 1, 1] =
 5  3
 2  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L48-L81)
```julia
vec(a::AbstractArray) -> AbstractVector
```
Reshape the array `a` as a one-dimensional column vector. Return `a` if it is already an `AbstractVector`. The resulting array shares the same underlying data as `a`, so it will only be mutable if `a` is mutable, in which case modifying one will also modify the other.
**Examples**
```julia-repl
julia> a = [1 2 3; 4 5 6]
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> vec(a)
6-element Vector{Int64}:
 1
 4
 2
 5
 3
 6

julia> vec(1:3)
1:3
```
See also [`reshape`](#Base.reshape), [`dropdims`](#Base.dropdims).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L11-L40)
```julia
SubArray{T,N,P,I,L} <: AbstractArray{T,N}
```
`N`-dimensional view into a parent array (of type `P`) with an element type `T`, restricted by a tuple of indices (of type `I`). `L` is true for types that support fast linear indexing, and `false` otherwise.
Construct `SubArray`s using the [`view`](#Base.view) function.


## [Views (SubArrays and other view types)](#Views-(SubArrays-and-other-view-types))
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/subarray.jl#L7-L13)


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia
cat(A...; dims)
```
Concatenate the input arrays along the dimensions specified in `dims`.
Along a dimension `d in dims`, the size of the output array is `sum(size(a,d) for a in A)`. Along other dimensions, all input arrays should have the same size, which will also be the size of the output array along those dimensions.
If `dims` is a single number, the different arrays are tightly packed along that dimension. If `dims` is an iterable containing several dimensions, the positions along these dimensions are increased simultaneously for each input array, filling with zero elsewhere. This allows one to construct block-diagonal matrices as `cat(matrices...; dims=(1,2))`, and their higher-dimensional analogues.
The special case `dims=1` is [`vcat`](#Base.vcat), and `dims=2` is [`hcat`](#Base.hcat). See also [`hvcat`](#Base.hvcat), [`hvncat`](#Base.hvncat), [`stack`](#Base.stack), [`repeat`](#Base.repeat).
The keyword also accepts `Val(dims)`.
For multiple dimensions `dims = Val(::Tuple)` was added in Julia 1.8.
**Examples**
Concatenate two arrays in different dimensions:
```julia-repl
julia> a = [1 2 3]
1×3 Matrix{Int64}:
 1  2  3

julia> b = [4 5 6]
1×3 Matrix{Int64}:
 4  5  6

julia> cat(a, b; dims=1)
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> cat(a, b; dims=2)
1×6 Matrix{Int64}:
 1  2  3  4  5  6

julia> cat(a, b; dims=(1, 2))
2×6 Matrix{Int64}:
 1  2  3  0  0  0
 0  0  0  4  5  6
```
**Extended Help**
Concatenate 3D arrays:


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> a = ones(2, 2, 3);

julia> b = ones(2, 2, 4);

julia> c = cat(a, b; dims=3);

julia> size(c) == (2, 2, 7)
true
```
Concatenate arrays of different sizes:
```julia-repl
julia> cat([1 2; 3 4], [pi, pi], fill(10, 2,3,1); dims=2)  # same as hcat
2×6×1 Array{Float64, 3}:
[:, :, 1] =
 1.0  2.0  3.14159  10.0  10.0  10.0
 3.0  4.0  3.14159  10.0  10.0  10.0
```
Construct a block diagonal matrix:
```julia
julia> cat(true, trues(2,2), trues(4)', dims=(1,2))  # block-diagonal
4×7 Matrix{Bool}:
 1  0  0  0  0  0  0
 0  1  1  0  0  0  0
 0  1  1  0  0  0  0
 0  0  0  1  1  1  1
```
```julia
julia> cat(1, [2], [3;;]; dims=Val(2))
1×3 Matrix{Int64}:
 1  2  3
```
`cat` does not join two strings, you may want to use `*`.
```julia-repl
julia> a = "aaa";

julia> b = "bbb";

julia> cat(a, b; dims=1)
2-element Vector{String}:
 "aaa"
 "bbb"

julia> cat(a, b; dims=2)
1×2 Matrix{String}:
 "aaa"  "bbb"

julia> a * b
"aaabbb"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1973-L2083)
```julia
vcat(A...)
```
Concatenate arrays or numbers vertically. Equivalent to [`cat`](#Base.cat)`(A...; dims=1)`, and to the syntax `[a; b; c]`.
To concatenate a large vector of arrays, `reduce(vcat, A)` calls an efficient method when `A isa AbstractVector{<:AbstractVecOrMat}`, rather than working pairwise.
See also [`hcat`](#Base.hcat), [`Iterators.flatten`](../iterators/#Base.Iterators.flatten), [`stack`](#Base.stack).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> v = vcat([1,2], [3,4])
4-element Vector{Int64}:
 1
 2
 3
 4

julia> v == vcat(1, 2, [3,4])  # accepts numbers
true

julia> v == [1; 2; [3,4]]  # syntax for the same operation
true

julia> summary(ComplexF64[1; 2; [3,4]])  # syntax for supplying the element type
"4-element Vector{ComplexF64}"

julia> vcat(range(1, 2, length=3))  # collects lazy ranges
3-element Vector{Float64}:
 1.0
 1.5
 2.0

julia> two = ([10, 20, 30]', Float64[4 5 6; 7 8 9])  # row vector and a matrix
([10 20 30], [4.0 5.0 6.0; 7.0 8.0 9.0])

julia> vcat(two...)
3×3 Matrix{Float64}:
 10.0  20.0  30.0
  4.0   5.0   6.0
  7.0   8.0   9.0

julia> vs = [[1, 2], [3, 4], [5, 6]];

julia> reduce(vcat, vs)  # more efficient than vcat(vs...)
6-element Vector{Int64}:
 1
 2
 3
 4
 5
 6

julia> ans == collect(Iterators.flatten(vs))
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1859-L1917)
```julia
hcat(A...)
```
Concatenate arrays or numbers horizontally. Equivalent to [`cat`](#Base.cat)`(A...; dims=2)`, and to the syntax `[a b c]` or `[a;; b;; c]`.
For a large vector of arrays, `reduce(hcat, A)` calls an efficient method when `A isa AbstractVector{<:AbstractVecOrMat}`. For a vector of vectors, this can also be written [`stack`](#Base.stack)`(A)`.
See also [`vcat`](#Base.vcat), [`hvcat`](#Base.hvcat).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> hcat([1,2], [3,4], [5,6])
2×3 Matrix{Int64}:
 1  3  5
 2  4  6

julia> hcat(1, 2, [30 40], [5, 6, 7]')  # accepts numbers
1×7 Matrix{Int64}:
 1  2  30  40  5  6  7

julia> ans == [1 2 [30 40] [5, 6, 7]']  # syntax for the same operation
true

julia> Float32[1 2 [30 40] [5, 6, 7]']  # syntax for supplying the eltype
1×7 Matrix{Float32}:
 1.0  2.0  30.0  40.0  5.0  6.0  7.0

julia> ms = [zeros(2,2), [1 2; 3 4], [50 60; 70 80]];

julia> reduce(hcat, ms)  # more efficient than hcat(ms...)
2×6 Matrix{Float64}:
 0.0  0.0  1.0  2.0  50.0  60.0
 0.0  0.0  3.0  4.0  70.0  80.0

julia> stack(ms) |> summary  # disagrees on a vector of matrices
"2×2×3 Array{Float64, 3}"

julia> hcat(Int[], Int[], Int[])  # empty vectors, each of size (0,)
0×3 Matrix{Int64}

julia> hcat([1.1, 9.9], Matrix(undef, 2, 0))  # hcat with empty 2×0 Matrix
2×1 Matrix{Any}:
 1.1
 9.9
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L1919-L1967)
```julia
hvcat(blocks_per_row::Union{Tuple{Vararg{Int}}, Int}, values...)
```
Horizontal and vertical concatenation in one call. This function is called for block matrix syntax. The first argument specifies the number of arguments to concatenate in each block row. If the first argument is a single integer `n`, then all block rows are assumed to have `n` block columns.
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1, 2, 3, 4, 5, 6)

julia> [a b c; d e f]
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> hvcat((3,3), a,b,c,d,e,f)
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> [a b; c d; e f]
3×2 Matrix{Int64}:
 1  2
 3  4
 5  6

julia> hvcat((2,2,2), a,b,c,d,e,f)
3×2 Matrix{Int64}:
 1  2
 3  4
 5  6
julia> hvcat((2,2,2), a,b,c,d,e,f) == hvcat(2, a,b,c,d,e,f)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L2121-L2158)
```julia
hvncat(dim::Int, row_first, values...)
hvncat(dims::Tuple{Vararg{Int}}, row_first, values...)
hvncat(shape::Tuple{Vararg{Tuple}}, row_first, values...)
```
Horizontal, vertical, and n-dimensional concatenation of many `values` in one call.


## [Concatenation and permutation](#Concatenation-and-permutation)
This function is called for block matrix syntax. The first argument either specifies the shape of the concatenation, similar to `hvcat`, as a tuple of tuples, or the dimensions that specify the key number of elements along each axis, and is used to determine the output dimensions. The `dims` form is more performant, and is used by default when the concatenation operation has the same number of elements along each axis (e.g., \[a b; c d;;; e f ; g h\]). The `shape` form is used when the number of elements along each axis is unbalanced (e.g., \[a b ; c\]). Unbalanced syntax needs additional validation overhead. The `dim` form is an optimization for concatenation along just one dimension. `row_first` indicates how `values` are ordered. The meaning of the first and second elements of `shape` are also swapped based on `row_first`.
**Examples**
```julia-repl
julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1, 2, 3, 4, 5, 6)

julia> [a b c;;; d e f]
1×3×2 Array{Int64, 3}:
[:, :, 1] =
 1  2  3

[:, :, 2] =
 4  5  6

julia> hvncat((2,1,3), false, a,b,c,d,e,f)
2×1×3 Array{Int64, 3}:
[:, :, 1] =
 1
 2

[:, :, 2] =
 3
 4

[:, :, 3] =
 5
 6

julia> [a b;;; c d;;; e f]
1×2×3 Array{Int64, 3}:
[:, :, 1] =
 1  2

[:, :, 2] =
 3  4

[:, :, 3] =
 5  6

julia> hvncat(((3, 3), (3, 3), (6,)), true, a, b, c, d, e, f)
1×3×2 Array{Int64, 3}:
[:, :, 1] =
 1  2  3

[:, :, 2] =
 4  5  6
```
**Examples for construction of the arguments**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia
[a b c ; d e f ;;;
 g h i ; j k l ;;;
 m n o ; p q r ;;;
 s t u ; v w x]
⇒ dims = (2, 3, 4)

[a b ; c ;;; d ;;;;]
 ___   _     _
 2     1     1 = elements in each row (2, 1, 1)
 _______     _
 3           1 = elements in each column (3, 1)
 _____________
 4             = elements in each 3d slice (4,)
 _____________
 4             = elements in each 4d slice (4,)
⇒ shape = ((2, 1, 1), (3, 1), (4,), (4,)) with `row_first` = true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L2274-L2358)
```julia
stack(iter; [dims])
```
Combine a collection of arrays (or other iterable objects) of equal size into one larger array, by arranging them along one or more new dimensions.
By default the axes of the elements are placed first, giving `size(result) = (size(first(iter))..., size(iter)...)`. This has the same order of elements as [`Iterators.flatten`](../iterators/#Base.Iterators.flatten)`(iter)`.
With keyword `dims::Integer`, instead the `i`th element of `iter` becomes the slice [`selectdim`](#Base.selectdim)`(result, dims, i)`, so that `size(result, dims) == length(iter)`. In this case `stack` reverses the action of [`eachslice`](#Base.eachslice) with the same `dims`.
The various [`cat`](#Base.cat) functions also combine arrays. However, these all extend the arrays' existing (possibly trivial) dimensions, rather than placing the arrays along new dimensions. They also accept arrays as separate arguments, rather than a single collection.


## [Concatenation and permutation](#Concatenation-and-permutation)
This function requires at least Julia 1.9.
**Examples**
```julia-repl
julia> vecs = (1:2, [30, 40], Float32[500, 600]);

julia> mat = stack(vecs)
2×3 Matrix{Float32}:
 1.0  30.0  500.0
 2.0  40.0  600.0

julia> mat == hcat(vecs...) == reduce(hcat, collect(vecs))
true

julia> vec(mat) == vcat(vecs...) == reduce(vcat, collect(vecs))
true

julia> stack(zip(1:4, 10:99))  # accepts any iterators of iterators
2×4 Matrix{Int64}:
  1   2   3   4
 10  11  12  13

julia> vec(ans) == collect(Iterators.flatten(zip(1:4, 10:99)))
true

julia> stack(vecs; dims=1)  # unlike any cat function, 1st axis of vecs[1] is 2nd axis of result
3×2 Matrix{Float32}:
   1.0    2.0
  30.0   40.0
 500.0  600.0

julia> x = rand(3,4);

julia> x == stack(eachcol(x)) == stack(eachrow(x), dims=1)  # inverse of eachslice
true
```
Higher-dimensional examples:


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> A = rand(5, 7, 11);

julia> E = eachslice(A, dims=2);  # a vector of matrices

julia> (element = size(first(E)), container = size(E))
(element = (5, 11), container = (7,))

julia> stack(E) |> size
(5, 11, 7)

julia> stack(E) == stack(E; dims=3) == cat(E...; dims=3)
true

julia> A == stack(E; dims=2)
true

julia> M = (fill(10i+j, 2, 3) for i in 1:5, j in 1:7);

julia> (element = size(first(M)), container = size(M))
(element = (2, 3), container = (5, 7))

julia> stack(M) |> size  # keeps all dimensions
(2, 3, 5, 7)

julia> stack(M; dims=1) |> size  # vec(container) along dims=1
(35, 2, 3)

julia> hvcat(5, M...) |> size  # hvcat puts matrices next to each other
(14, 15)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L2767-L2857)
```julia
stack(f, args...; [dims])
```
Apply a function to each element of a collection, and `stack` the result. Or to several collections, [`zip`](../iterators/#Base.Iterators.zip)ped together.
The function should return arrays (or tuples, or other iterators) all of the same size. These become slices of the result, each separated along `dims` (if given) or by default along the last dimensions.
See also [`mapslices`](#Base.mapslices), [`eachcol`](#Base.eachcol).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> stack(c -> (c, c-32), "julia")
2×5 Matrix{Char}:
 'j'  'u'  'l'  'i'  'a'
 'J'  'U'  'L'  'I'  'A'

julia> stack(eachrow([1 2 3; 4 5 6]), (10, 100); dims=1) do row, n
         vcat(row, row .* n, row ./ n)
       end
2×9 Matrix{Float64}:
 1.0  2.0  3.0   10.0   20.0   30.0  0.1   0.2   0.3
 4.0  5.0  6.0  400.0  500.0  600.0  0.04  0.05  0.06
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L2860-L2886)
```julia
vect(X...)
```
Create a [`Vector`](#Base.Vector) with element type computed from the `promote_typeof` of the argument, containing the argument list.
**Examples**
```julia-repl
julia> a = Base.vect(UInt8(1), 2.5, 1//2)
3-element Vector{Float64}:
 1.0
 2.5
 0.5
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L168-L182)
```julia
circshift(A, shifts)
```
Circularly shift, i.e. rotate, the data in an array. The second argument is a tuple or vector giving the amount to shift in each dimension, or an integer to shift only in the first dimension.
See also: [`circshift!`](#Base.circshift!), [`circcopy!`](#Base.circcopy!), [`bitrotate`](../math/#Base.bitrotate), [`<<`](../math/#Base.:%3C%3C).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> b = reshape(Vector(1:16), (4,4))
4×4 Matrix{Int64}:
 1  5   9  13
 2  6  10  14
 3  7  11  15
 4  8  12  16

julia> circshift(b, (0,2))
4×4 Matrix{Int64}:
  9  13  1  5
 10  14  2  6
 11  15  3  7
 12  16  4  8

julia> circshift(b, (-1,0))
4×4 Matrix{Int64}:
 2  6  10  14
 3  7  11  15
 4  8  12  16
 1  5   9  13

julia> a = BitArray([true, true, false, false, true])
5-element BitVector:
 1
 1
 0
 0
 1

julia> circshift(a, 1)
5-element BitVector:
 1
 1
 1
 0
 0

julia> circshift(a, -1)
5-element BitVector:
 1
 0
 0
 1
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L265-L321)
```julia
circshift!(a::AbstractVector, shift::Integer)
```
Circularly shift, or rotate, the data in vector `a` by `shift` positions.
**Examples**
```julia-repl
julia> circshift!([1, 2, 3, 4, 5], 2)
5-element Vector{Int64}:
 4
 5
 1
 2
 3

julia> circshift!([1, 2, 3, 4, 5], -2)
5-element Vector{Int64}:
 3
 4
 5
 1
 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3664-L3688)
```julia
circshift!(dest, src, shifts)
```
Circularly shift, i.e. rotate, the data in `src`, storing the result in `dest`. `shifts` specifies the amount to shift in each dimension.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also [`circshift`](#Base.circshift).


## [Concatenation and permutation](#Concatenation-and-permutation)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L1206-L1215)
```julia
circcopy!(dest, src)
```
Copy `src` to `dest`, indexing each dimension modulo its length. `src` and `dest` must have the same size, but can be offset in their indices; any offset results in a (circular) wraparound. If the arrays have overlapping indices, then on the domain of the overlap `dest` agrees with `src`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also: [`circshift`](#Base.circshift).
**Examples**
```julia-repl
julia> src = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
 1  5   9  13
 2  6  10  14
 3  7  11  15
 4  8  12  16

julia> dest = OffsetArray{Int}(undef, (0:3,2:5))

julia> circcopy!(dest, src)
OffsetArrays.OffsetArray{Int64,2,Array{Int64,2}} with indices 0:3×2:5:
 8  12  16  4
 5   9  13  1
 6  10  14  2
 7  11  15  3

julia> dest[1:3,2:4] == src[1:3,2:4]
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L1261-L1295)
```julia
findall(A)
```
Return a vector `I` of the `true` indices or keys of `A`. If there are no such elements of `A`, return an empty array. To search for other kinds of values, pass a predicate as the first argument.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).


## [Concatenation and permutation](#Concatenation-and-permutation)
See also: [`findfirst`](#Base.findfirst-Tuple%7BAny%7D), [`searchsorted`](../sort/#Base.Sort.searchsorted).
**Examples**
```julia-repl
julia> A = [true, false, false, true]
4-element Vector{Bool}:
 1
 0
 0
 1

julia> findall(A)
2-element Vector{Int64}:
 1
 4

julia> A = [true false; false true]
2×2 Matrix{Bool}:
 1  0
 0  1

julia> findall(A)
2-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 2)

julia> findall(falses(3))
Int64[]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2651-L2690)
```julia
findall(f::Function, A)
```
Return a vector `I` of the indices or keys of `A` where `f(A[I])` returns `true`. If there are no such elements of `A`, return an empty array.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> x = [1, 3, 4]
3-element Vector{Int64}:
 1
 3
 4

julia> findall(isodd, x)
2-element Vector{Int64}:
 1
 2

julia> A = [1 2 0; 3 4 0]
2×3 Matrix{Int64}:
 1  2  0
 3  4  0
julia> findall(isodd, A)
2-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)

julia> findall(!iszero, A)
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)
 CartesianIndex(1, 2)
 CartesianIndex(2, 2)

julia> d = Dict(:A => 10, :B => -1, :C => 0)
Dict{Symbol, Int64} with 3 entries:
  :A => 10
  :B => -1
  :C => 0

julia> findall(x -> x >= 0, d)
2-element Vector{Symbol}:
 :A
 :C
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2591-L2641)
```julia
findfirst(A)
```
Return the index or key of the first `true` value in `A`. Return `nothing` if no such value is found. To search for other kinds of values, pass a predicate as the first argument.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
See also: [`findall`](#Base.findall-Tuple%7BAny%7D), [`findnext`](#Base.findnext-Tuple%7BAny,%20Integer%7D), [`findlast`](#Base.findlast-Tuple%7BAny%7D), [`searchsortedfirst`](../sort/#Base.Sort.searchsortedfirst).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> A = [false, false, true, false]
4-element Vector{Bool}:
 0
 0
 1
 0

julia> findfirst(A)
3

julia> findfirst(falses(3)) # returns nothing, but not printed in the REPL

julia> A = [false false; true false]
2×2 Matrix{Bool}:
 0  0
 1  0

julia> findfirst(A)
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2279-L2313)
```julia
findfirst(predicate::Function, A)
```
Return the index or key of the first element of `A` for which `predicate` returns `true`. Return `nothing` if there is no such element.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**
```julia-repl
julia> A = [1, 4, 2, 2]
4-element Vector{Int64}:
 1
 4
 2
 2

julia> findfirst(iseven, A)
2

julia> findfirst(x -> x>10, A) # returns nothing, but not printed in the REPL

julia> findfirst(isequal(4), A)
2

julia> A = [1 4; 2 2]
2×2 Matrix{Int64}:
 1  4
 2  2

julia> findfirst(iseven, A)
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2361-L2395)
```julia
findlast(A)
```
Return the index or key of the last `true` value in `A`. Return `nothing` if there is no `true` value in `A`.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).


## [Concatenation and permutation](#Concatenation-and-permutation)
See also: [`findfirst`](#Base.findfirst-Tuple%7BAny%7D), [`findprev`](#Base.findprev-Tuple%7BAny,%20Integer%7D), [`findall`](#Base.findall-Tuple%7BAny%7D).
**Examples**
```julia-repl
julia> A = [true, false, true, false]
4-element Vector{Bool}:
 1
 0
 1
 0

julia> findlast(A)
3

julia> A = falses(2,2);

julia> findlast(A) # returns nothing, but not printed in the REPL

julia> A = [true false; true false]
2×2 Matrix{Bool}:
 1  0
 1  0

julia> findlast(A)
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2457-L2492)
```julia
findlast(predicate::Function, A)
```
Return the index or key of the last element of `A` for which `predicate` returns `true`. Return `nothing` if there is no such element.
Indices or keys are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**
```julia-repl
julia> A = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> findlast(isodd, A)
3

julia> findlast(x -> x > 5, A) # returns nothing, but not printed in the REPL

julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> findlast(isodd, A)
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2548-L2579)
```julia
findnext(A, i)
```
Find the next index after or including `i` of a `true` element of `A`, or `nothing` if not found.


## [Concatenation and permutation](#Concatenation-and-permutation)
Indices are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**
```julia-repl
julia> A = [false, false, true, false]
4-element Vector{Bool}:
 0
 0
 1
 0

julia> findnext(A, 1)
3

julia> findnext(A, 4) # returns nothing, but not printed in the REPL

julia> A = [false false; true false]
2×2 Matrix{Bool}:
 0  0
 1  0

julia> findnext(A, CartesianIndex(1, 1))
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2245-L2276)
```julia
findnext(predicate::Function, A, i)
```
Find the next index after or including `i` of an element of `A` for which `predicate` returns `true`, or `nothing` if not found. This works for Arrays, Strings, and most other collections that support [`getindex`](../collections/#Base.getindex), [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D), and [`nextind`](#Base.nextind).
Indices are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**
```julia-repl
julia> A = [1, 4, 2, 2];

julia> findnext(isodd, A, 1)
1

julia> findnext(isodd, A, 2) # returns nothing, but not printed in the REPL

julia> A = [1 4; 2 2];

julia> findnext(isodd, A, CartesianIndex(1, 1))
CartesianIndex(1, 1)

julia> findnext(isspace, "a b c", 3)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2319-L2347)


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia
findprev(A, i)
```
Find the previous index before or including `i` of a `true` element of `A`, or `nothing` if not found.
Indices are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
See also: [`findnext`](#Base.findnext-Tuple%7BAny,%20Integer%7D), [`findfirst`](#Base.findfirst-Tuple%7BAny%7D), [`findall`](#Base.findall-Tuple%7BAny%7D).
**Examples**
```julia-repl
julia> A = [false, false, true, true]
4-element Vector{Bool}:
 0
 0
 1
 1

julia> findprev(A, 3)
3

julia> findprev(A, 1) # returns nothing, but not printed in the REPL

julia> A = [false false; true true]
2×2 Matrix{Bool}:
 0  0
 1  1

julia> findprev(A, CartesianIndex(2, 1))
CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2421-L2454)
```julia
findprev(predicate::Function, A, i)
```
Find the previous index before or including `i` of an element of `A` for which `predicate` returns `true`, or `nothing` if not found. This works for Arrays, Strings, and most other collections that support [`getindex`](../collections/#Base.getindex), [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D), and [`nextind`](#Base.nextind).
Indices are of the same type as those returned by [`keys(A)`](#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(A)`](../collections/#Base.pairs).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> A = [4, 6, 1, 2]
4-element Vector{Int64}:
 4
 6
 1
 2

julia> findprev(isodd, A, 1) # returns nothing, but not printed in the REPL

julia> findprev(isodd, A, 3)
3

julia> A = [4 6; 1 2]
2×2 Matrix{Int64}:
 4  6
 1  2

julia> findprev(isodd, A, CartesianIndex(1, 2))
CartesianIndex(2, 1)

julia> findprev(isspace, "a b c", 3)
2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2498-L2534)
```julia
permutedims(A::AbstractArray, perm)
permutedims(A::AbstractMatrix)
```
Permute the dimensions (axes) of array `A`. `perm` is a tuple or vector of `ndims(A)` integers specifying the permutation.
If `A` is a 2d array ([`AbstractMatrix`](#Base.AbstractMatrix)), then `perm` defaults to `(2,1)`, swapping the two axes of `A` (the rows and columns of the matrix). This differs from [`transpose`](../../stdlib/LinearAlgebra/#Base.transpose) in that the operation is not recursive, which is especially useful for arrays of non-numeric values (where the recursive `transpose` would throw an error) and/or 2d arrays that do not represent linear operators.
For 1d arrays, see [`permutedims(v::AbstractVector)`](#Base.permutedims), which returns a 1-row “matrix”.
See also [`permutedims!`](#Base.permutedims!), [`PermutedDimsArray`](#Base.PermutedDimsArrays.PermutedDimsArray), [`transpose`](../../stdlib/LinearAlgebra/#Base.transpose), [`invperm`](#Base.invperm).
**Examples**
**2d arrays:**


## [Concatenation and permutation](#Concatenation-and-permutation)
Unlike `transpose`, `permutedims` can be used to swap rows and columns of 2d arrays of arbitrary non-numeric elements, such as strings:
```julia-repl
julia> A = ["a" "b" "c"
            "d" "e" "f"]
2×3 Matrix{String}:
 "a"  "b"  "c"
 "d"  "e"  "f"

julia> permutedims(A)
3×2 Matrix{String}:
 "a"  "d"
 "b"  "e"
 "c"  "f"
```
And `permutedims` produces results that differ from `transpose` for matrices whose elements are themselves numeric matrices:
```julia-repl
julia> a = [1 2; 3 4];

julia> b = [5 6; 7 8];

julia> c = [9 10; 11 12];

julia> d = [13 14; 15 16];

julia> X = [[a] [b]; [c] [d]]
2×2 Matrix{Matrix{Int64}}:
 [1 2; 3 4]     [5 6; 7 8]
 [9 10; 11 12]  [13 14; 15 16]

julia> permutedims(X)
2×2 Matrix{Matrix{Int64}}:
 [1 2; 3 4]  [9 10; 11 12]
 [5 6; 7 8]  [13 14; 15 16]

julia> transpose(X)
2×2 transpose(::Matrix{Matrix{Int64}}) with eltype Transpose{Int64, Matrix{Int64}}:
 [1 3; 2 4]  [9 11; 10 12]
 [5 7; 6 8]  [13 15; 14 16]
```
**Multi-dimensional arrays**
```julia-repl
julia> A = reshape(Vector(1:8), (2,2,2))
2×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  3
 2  4

[:, :, 2] =
 5  7
 6  8

julia> perm = (3, 1, 2); # put the last dimension first

julia> B = permutedims(A, perm)
2×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  2
 5  6

[:, :, 2] =
 3  4
 7  8

julia> A == permutedims(B, invperm(perm)) # the inverse permutation
true
```
For each dimension `i` of `B = permutedims(A, perm)`, its corresponding dimension of `A` will be `perm[i]`. This means the equality `size(B, i) == size(A, perm[i])` holds.


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> A = randn(5, 7, 11, 13);

julia> perm = [4, 1, 3, 2];

julia> B = permutedims(A, perm);

julia> size(B)
(13, 5, 11, 7)

julia> size(A)[perm] == ans
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/permuteddimsarray.jl#L88-L195)
```julia
permutedims(v::AbstractVector)
```
Reshape vector `v` into a `1 × length(v)` row matrix. Differs from [`transpose`](../../stdlib/LinearAlgebra/#Base.transpose) in that the operation is not recursive, which is especially useful for arrays of non-numeric values (where the recursive `transpose` might throw an error).
**Examples**
Unlike `transpose`, `permutedims` can be used on vectors of arbitrary non-numeric elements, such as strings:
```julia-repl
julia> permutedims(["a", "b", "c"])
1×3 Matrix{String}:
 "a"  "b"  "c"
```
For vectors of numbers, `permutedims(v)` works much like `transpose(v)` except that the return type differs (it uses [`reshape`](#Base.reshape) rather than a `LinearAlgebra.Transpose` view, though both share memory with the original array `v`):
```julia-repl
julia> v = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> p = permutedims(v)
1×4 Matrix{Int64}:
 1  2  3  4

julia> r = transpose(v)
1×4 transpose(::Vector{Int64}) with eltype Int64:
 1  2  3  4

julia> p == r
true

julia> typeof(r)
Transpose{Int64, Vector{Int64}}

julia> p[1] = 5; r[2] = 6; # mutating p or r also changes v

julia> v # shares memory with both p and r
4-element Vector{Int64}:
 5
 6
 3
 4
```


## [Concatenation and permutation](#Concatenation-and-permutation)
However, `permutedims` produces results that differ from `transpose` for vectors whose elements are themselves numeric matrices:
```julia-repl
julia> V = [[[1 2; 3 4]]; [[5 6; 7 8]]]
2-element Vector{Matrix{Int64}}:
 [1 2; 3 4]
 [5 6; 7 8]

julia> permutedims(V)
1×2 Matrix{Matrix{Int64}}:
 [1 2; 3 4]  [5 6; 7 8]

julia> transpose(V)
1×2 transpose(::Vector{Matrix{Int64}}) with eltype Transpose{Int64, Matrix{Int64}}:
 [1 3; 2 4]  [5 7; 6 8]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/permuteddimsarray.jl#L203-L270)
```julia
permutedims!(dest, src, perm)
```
Permute the dimensions of array `src` and store the result in the array `dest`. `perm` is a vector specifying a permutation of length `ndims(src)`. The preallocated array `dest` should have `size(dest) == size(src)[perm]` and is completely overwritten. No in-place permutation is supported and unexpected results will happen if `src` and `dest` have overlapping memory regions.
See also [`permutedims`](#Base.permutedims).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/permuteddimsarray.jl#L273-L283)
```julia
PermutedDimsArray(A, perm) -> B
```
Given an AbstractArray `A`, create a view `B` such that the dimensions appear to be permuted. Similar to `permutedims`, except that no copying occurs (`B` shares storage with `A`).
See also [`permutedims`](#Base.permutedims), [`invperm`](#Base.invperm).
**Examples**


## [Concatenation and permutation](#Concatenation-and-permutation)
```julia-repl
julia> A = rand(3,5,4);

julia> B = PermutedDimsArray(A, (3,1,2));

julia> size(B)
(4, 3, 5)

julia> B[3,1,2] == A[1,2,3]
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/permuteddimsarray.jl#L20-L41)
```julia
promote_shape(s1, s2)
```
Check two array shapes for compatibility, allowing trailing singleton dimensions, and return whichever shape has more dimensions.
**Examples**
```julia-repl
julia> a = fill(1, (3,4,1,1,1));

julia> b = fill(1, (3,4));

julia> promote_shape(a,b)
(Base.OneTo(3), Base.OneTo(4), Base.OneTo(1), Base.OneTo(1), Base.OneTo(1))

julia> promote_shape((2,3,1,4), (2, 3, 1, 4, 1))
(2, 3, 1, 4, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/indices.jl#L155-L173)


## [Array functions](#Array-functions)
```julia
accumulate(op, A; dims::Integer, [init])
```
Cumulative operation `op` along the dimension `dims` of `A` (providing `dims` is optional for vectors). An initial value `init` may optionally be provided by a keyword argument. See also [`accumulate!`](#Base.accumulate!) to use a preallocated output array, both for performance and to control the precision of the output (e.g. to avoid overflow).
For common operations there are specialized variants of `accumulate`, see [`cumsum`](#Base.cumsum), [`cumprod`](#Base.cumprod). For a lazy version, see [`Iterators.accumulate`](../iterators/#Base.Iterators.accumulate).
`accumulate` on a non-array iterator requires at least Julia 1.5.
**Examples**
```julia-repl
julia> accumulate(+, [1,2,3])
3-element Vector{Int64}:
 1
 3
 6

julia> accumulate(min, (1, -2, 3, -4, 5), init=0)
(0, -2, -2, -4, -4)

julia> accumulate(/, (2, 4, Inf), init=100)
(50.0, 12.5, 0.0)

julia> accumulate(=>, i^2 for i in 1:3)
3-element Vector{Any}:
          1
        1 => 4
 (1 => 4) => 9

julia> accumulate(+, fill(1, 3, 4))
3×4 Matrix{Int64}:
 1  4  7  10
 2  5  8  11
 3  6  9  12

julia> accumulate(+, fill(1, 2, 5), dims=2, init=100.0)
2×5 Matrix{Float64}:
 101.0  102.0  103.0  104.0  105.0
 101.0  102.0  103.0  104.0  105.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L234-L280)
```julia
accumulate!(op, B, A; [dims], [init])
```


## [Array functions](#Array-functions)
Cumulative operation `op` on `A` along the dimension `dims`, storing the result in `B`. Providing `dims` is optional for vectors. If the keyword argument `init` is given, its value is used to instantiate the accumulation.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also [`accumulate`](#Base.accumulate), [`cumsum!`](#Base.cumsum!), [`cumprod!`](#Base.cumprod!).
**Examples**
```julia-repl
julia> x = [1, 0, 2, 0, 3];

julia> y = rand(5);

julia> accumulate!(+, y, x);

julia> y
5-element Vector{Float64}:
 1.0
 1.0
 3.0
 3.0
 6.0

julia> A = [1 2 3; 4 5 6];

julia> B = similar(A);

julia> accumulate!(-, B, A, dims=1)
2×3 Matrix{Int64}:
  1   2   3
 -3  -3  -3

julia> accumulate!(*, B, A, dims=2, init=10)
2×3 Matrix{Int64}:
 10   20    60
 40  200  1200
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L306-L347)
```julia
cumprod(A; dims::Integer)
```
Cumulative product along the dimension `dim`. See also [`cumprod!`](#Base.cumprod!) to use a preallocated output array, both for performance and to control the precision of the output (e.g. to avoid overflow).
**Examples**
```julia-repl
julia> a = Int8[1 2 3; 4 5 6];

julia> cumprod(a, dims=1)
2×3 Matrix{Int64}:
 1   2   3
 4  10  18

julia> cumprod(a, dims=2)
2×3 Matrix{Int64}:
 1   2    6
 4  20  120
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L174-L195)
```julia
cumprod(itr)
```


## [Array functions](#Array-functions)
Cumulative product of an iterator.
See also [`cumprod!`](#Base.cumprod!), [`accumulate`](#Base.accumulate), [`cumsum`](#Base.cumsum).
`cumprod` on a non-array iterator requires at least Julia 1.5.
**Examples**
```julia-repl
julia> cumprod(fill(1//2, 3))
3-element Vector{Rational{Int64}}:
 1//2
 1//4
 1//8

julia> cumprod((1, 2, 1, 3, 1))
(1, 2, 2, 6, 6)

julia> cumprod("julia")
5-element Vector{String}:
 "j"
 "ju"
 "jul"
 "juli"
 "julia"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L200-L229)
```julia
cumprod!(B, A; dims::Integer)
```
Cumulative product of `A` along the dimension `dims`, storing the result in `B`. See also [`cumprod`](#Base.cumprod).
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L153-L160)
```julia
cumprod!(y::AbstractVector, x::AbstractVector)
```
Cumulative product of a vector `x`, storing the result in `y`. See also [`cumprod`](#Base.cumprod).
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L164-L171)
```julia
cumsum(A; dims::Integer)
```
Cumulative sum along the dimension `dims`. See also [`cumsum!`](#Base.cumsum!) to use a preallocated output array, both for performance and to control the precision of the output (e.g. to avoid overflow).


## [Array functions](#Array-functions)
**Examples**
```julia-repl
julia> a = [1 2 3; 4 5 6]
2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> cumsum(a, dims=1)
2×3 Matrix{Int64}:
 1  2  3
 5  7  9

julia> cumsum(a, dims=2)
2×3 Matrix{Int64}:
 1  3   6
 4  9  15
```
The return array's `eltype` is `Int` for signed integers of less than system word size and `UInt` for unsigned integers of less than system word size. To preserve `eltype` of arrays with small signed or unsigned integer `accumulate(+, A)` should be used.
```julia-repl
julia> cumsum(Int8[100, 28])
2-element Vector{Int64}:
 100
 128

julia> accumulate(+,Int8[100, 28])
2-element Vector{Int8}:
  100
 -128
```
In the former case, the integers are widened to system word size and therefore the result is `Int64[100, 128]`. In the latter case, no such widening happens and integer overflow results in `Int8[100, -128]`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L69-L115)
```julia
cumsum(itr)
```
Cumulative sum of an iterator.
See also [`accumulate`](#Base.accumulate) to apply functions other than `+`.
`cumsum` on a non-array iterator requires at least Julia 1.5.
**Examples**
```julia-repl
julia> cumsum(1:3)
3-element Vector{Int64}:
 1
 3
 6

julia> cumsum((true, false, true, false, true))
(1, 1, 2, 2, 3)

julia> cumsum(fill(1, 2) for i in 1:3)
3-element Vector{Vector{Int64}}:
 [1, 1]
 [2, 2]
 [3, 3]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L121-L148)
```julia
cumsum!(B, A; dims::Integer)
```


## [Array functions](#Array-functions)
Cumulative sum of `A` along the dimension `dims`, storing the result in `B`. See also [`cumsum`](#Base.cumsum).
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/accumulate.jl#L44-L50)
```julia
diff(A::AbstractVector)
diff(A::AbstractArray; dims::Integer)
```
Finite difference operator on a vector or a multidimensional array `A`. In the latter case the dimension to operate on needs to be specified with the `dims` keyword argument.
`diff` for arrays with dimension higher than 2 requires at least Julia 1.1.
**Examples**
```julia-repl
julia> a = [2 4; 6 16]
2×2 Matrix{Int64}:
 2   4
 6  16

julia> diff(a, dims=2)
2×1 Matrix{Int64}:
  2
 10

julia> diff(vec(a))
3-element Vector{Int64}:
  4
 -2
 12
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/multidimensional.jl#L1002-L1031)
```julia
repeat(A::AbstractArray, counts::Integer...)
```
Construct an array by repeating array `A` a given number of times in each dimension, specified by `counts`.
See also: [`fill`](#Base.fill), [`Iterators.repeated`](../iterators/#Base.Iterators.repeated), [`Iterators.cycle`](../iterators/#Base.Iterators.cycle).
**Examples**
```julia-repl
julia> repeat([1, 2, 3], 2)
6-element Vector{Int64}:
 1
 2
 3
 1
 2
 3

julia> repeat([1, 2, 3], 2, 3)
6×3 Matrix{Int64}:
 1  1  1
 2  2  2
 3  3  3
 1  1  1
 2  2  2
 3  3  3
```


## [Array functions](#Array-functions)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L328-L355)
```julia
repeat(A::AbstractArray; inner=ntuple(Returns(1), ndims(A)), outer=ntuple(Returns(1), ndims(A)))
```
Construct an array by repeating the entries of `A`. The i-th element of `inner` specifies the number of times that the individual entries of the i-th dimension of `A` should be repeated. The i-th element of `outer` specifies the number of times that a slice along the i-th dimension of `A` should be repeated. If `inner` or `outer` are omitted, no repetition is performed.
**Examples**
```julia-repl
julia> repeat(1:2, inner=2)
4-element Vector{Int64}:
 1
 1
 2
 2

julia> repeat(1:2, outer=2)
4-element Vector{Int64}:
 1
 2
 1
 2

julia> repeat([1 2; 3 4], inner=(2, 1), outer=(1, 3))
4×6 Matrix{Int64}:
 1  2  1  2  1  2
 1  2  1  2  1  2
 3  4  3  4  3  4
 3  4  3  4  3  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarraymath.jl#L360-L392)
```julia
repeat(s::AbstractString, r::Integer)
```
Repeat a string `r` times. This can be written as `s^r`.
See also [`^`](../strings/#Base.:%5E-Tuple%7BUnion%7BAbstractChar,%20AbstractString%7D,%20Integer%7D).
**Examples**
```julia-repl
julia> repeat("ha", 3)
"hahaha"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L751-L763)
```julia
repeat(c::AbstractChar, r::Integer) -> String
```


## [Array functions](#Array-functions)
Repeat a character `r` times. This can equivalently be accomplished by calling [`c^r`](../strings/#Base.:%5E-Tuple%7BUnion%7BAbstractChar,%20AbstractString%7D,%20Integer%7D).
**Examples**
```julia-repl
julia> repeat('A', 3)
"AAA"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/string.jl#L560-L571)
```julia
rot180(A)
```
Rotate matrix `A` 180 degrees.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rot180(a)
2×2 Matrix{Int64}:
 4  3
 2  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L158-L175)
```julia
rot180(A, k)
```
Rotate matrix `A` 180 degrees an integer `k` number of times. If `k` is even, this is equivalent to a `copy`.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rot180(a,1)
2×2 Matrix{Int64}:
 4  3
 2  1

julia> rot180(a,2)
2×2 Matrix{Int64}:
 1  2
 3  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L260-L283)
```julia
rotl90(A)
```
Rotate matrix `A` left 90 degrees.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rotl90(a)
2×2 Matrix{Int64}:
 2  4
 1  3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L103-L120)
```julia
rotl90(A, k)
```


## [Array functions](#Array-functions)
Left-rotate matrix `A` 90 degrees counterclockwise an integer `k` number of times. If `k` is a multiple of four (including zero), this is equivalent to a `copy`.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rotl90(a,1)
2×2 Matrix{Int64}:
 2  4
 1  3

julia> rotl90(a,2)
2×2 Matrix{Int64}:
 4  3
 2  1

julia> rotl90(a,3)
2×2 Matrix{Int64}:
 3  1
 4  2

julia> rotl90(a,4)
2×2 Matrix{Int64}:
 1  2
 3  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L185-L218)
```julia
rotr90(A)
```
Rotate matrix `A` right 90 degrees.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rotr90(a)
2×2 Matrix{Int64}:
 3  1
 4  2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L131-L148)
```julia
rotr90(A, k)
```
Right-rotate matrix `A` 90 degrees clockwise an integer `k` number of times. If `k` is a multiple of four (including zero), this is equivalent to a `copy`.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> rotr90(a,1)
2×2 Matrix{Int64}:
 3  1
 4  2

julia> rotr90(a,2)
2×2 Matrix{Int64}:
 4  3
 2  1

julia> rotr90(a,3)
2×2 Matrix{Int64}:
 2  4
 1  3

julia> rotr90(a,4)
2×2 Matrix{Int64}:
 1  2
 3  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L225-L258)
```julia
mapslices(f, A; dims)
```


## [Array functions](#Array-functions)
Transform the given dimensions of array `A` by applying a function `f` on each slice of the form `A[..., :, ..., :, ...]`, with a colon at each `d` in `dims`. The results are concatenated along the remaining dimensions.
For example, if `dims = [1,2]` and `A` is 4-dimensional, then `f` is called on `x = A[:,:,i,j]` for all `i` and `j`, and `f(x)` becomes `R[:,:,i,j]` in the result `R`.
See also [`eachcol`](#Base.eachcol) or [`eachslice`](#Base.eachslice), used with [`map`](../collections/#Base.map) or [`stack`](#Base.stack).
**Examples**
```julia-repl
julia> A = reshape(1:30,(2,5,3))
2×5×3 reshape(::UnitRange{Int64}, 2, 5, 3) with eltype Int64:
[:, :, 1] =
 1  3  5  7   9
 2  4  6  8  10

[:, :, 2] =
 11  13  15  17  19
 12  14  16  18  20

[:, :, 3] =
 21  23  25  27  29
 22  24  26  28  30

julia> f(x::Matrix) = fill(x[1,1], 1,4);  # returns a 1×4 matrix

julia> B = mapslices(f, A, dims=(1,2))
1×4×3 Array{Int64, 3}:
[:, :, 1] =
 1  1  1  1

[:, :, 2] =
 11  11  11  11

[:, :, 3] =
 21  21  21  21

julia> f2(x::AbstractMatrix) = fill(x[1,1], 1,4);

julia> B == stack(f2, eachslice(A, dims=3))
true

julia> g(x) = x[begin] // x[end-1];  # returns a number

julia> mapslices(g, A, dims=[1,3])
1×5×1 Array{Rational{Int64}, 3}:
[:, :, 1] =
 1//21  3//23  1//5  7//27  9//29

julia> map(g, eachslice(A, dims=2))
5-element Vector{Rational{Int64}}:
 1//21
 3//23
 1//5
 7//27
 9//29

julia> mapslices(sum, A; dims=(1,3)) == sum(A; dims=(1,3))
true
```


## [Array functions](#Array-functions)
Notice that in `eachslice(A; dims=2)`, the specified dimension is the one *without* a colon in the slice. This is `view(A,:,i,:)`, whereas `mapslices(f, A; dims=(1,3))` uses `A[:,i,:]`. The function `f` may mutate values in the slice without affecting `A`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3195-L3264)
```julia
eachrow(A::AbstractVecOrMat) <: AbstractVector
```
Create a [`RowSlices`](#Base.RowSlices) object that is a vector of rows of matrix or vector `A`. Row slices are returned as `AbstractVector` views of `A`.
For the inverse, see [`stack`](#Base.stack)`(rows; dims=1)`.
See also [`eachcol`](#Base.eachcol), [`eachslice`](#Base.eachslice) and [`mapslices`](#Base.mapslices).
This function requires at least Julia 1.1.
Prior to Julia 1.9, this returned an iterator.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> s = eachrow(a)
2-element RowSlices{Matrix{Int64}, Tuple{Base.OneTo{Int64}}, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}:
 [1, 2]
 [3, 4]

julia> s[1]
2-element view(::Matrix{Int64}, 1, :) with eltype Int64:
 1
 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L131-L165)
```julia
eachcol(A::AbstractVecOrMat) <: AbstractVector
```
Create a [`ColumnSlices`](#Base.ColumnSlices) object that is a vector of columns of matrix or vector `A`. Column slices are returned as `AbstractVector` views of `A`.


## [Array functions](#Array-functions)
For the inverse, see [`stack`](#Base.stack)`(cols)` or `reduce(`[`hcat`](#Base.hcat)`, cols)`.
See also [`eachrow`](#Base.eachrow), [`eachslice`](#Base.eachslice) and [`mapslices`](#Base.mapslices).
This function requires at least Julia 1.1.
Prior to Julia 1.9, this returned an iterator.
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> s = eachcol(a)
2-element ColumnSlices{Matrix{Int64}, Tuple{Base.OneTo{Int64}}, SubArray{Int64, 1, Matrix{Int64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}:
 [1, 3]
 [2, 4]

julia> s[1]
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
 1
 3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L169-L203)
```julia
eachslice(A::AbstractArray; dims, drop=true)
```
Create a [`Slices`](#Base.Slices) object that is an array of slices over dimensions `dims` of `A`, returning views that select all the data from the other dimensions in `A`. `dims` can either be an integer or a tuple of integers.
If `drop = true` (the default), the outer `Slices` will drop the inner dimensions, and the ordering of the dimensions will match those in `dims`. If `drop = false`, then the `Slices` will have the same dimensionality as the underlying array, with inner dimensions having size 1.
See [`stack`](#Base.stack)`(slices; dims)` for the inverse of `eachslice(A; dims::Integer)`.
See also [`eachrow`](#Base.eachrow), [`eachcol`](#Base.eachcol), [`mapslices`](#Base.mapslices) and [`selectdim`](#Base.selectdim).


## [Array functions](#Array-functions)
This function requires at least Julia 1.1.
Prior to Julia 1.9, this returned an iterator, and only a single dimension `dims` was supported.
**Examples**
```julia-repl
julia> m = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
 1  2  3
 4  5  6
 7  8  9

julia> s = eachslice(m, dims=1)
3-element RowSlices{Matrix{Int64}, Tuple{Base.OneTo{Int64}}, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}:
 [1, 2, 3]
 [4, 5, 6]
 [7, 8, 9]

julia> s[1]
3-element view(::Matrix{Int64}, 1, :) with eltype Int64:
 1
 2
 3

julia> eachslice(m, dims=1, drop=false)
3×1 Slices{Matrix{Int64}, Tuple{Int64, Colon}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}, 2}:
 [1, 2, 3]
 [4, 5, 6]
 [7, 8, 9]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/slicearray.jl#L77-L126)


## [Combinatorics](#Combinatorics)
```julia
invperm(v)
```
Return the inverse permutation of `v`. If `B = A[v]`, then `A == B[invperm(v)]`.
See also [`sortperm`](../sort/#Base.sortperm), [`invpermute!`](#Base.invpermute!), [`isperm`](#Base.isperm), [`permutedims`](#Base.permutedims).
**Examples**
```julia-repl
julia> p = (2, 3, 1);

julia> invperm(p)
(3, 1, 2)

julia> v = [2; 4; 3; 1];

julia> invperm(v)
4-element Vector{Int64}:
 4
 1
 3
 2

julia> A = ['a','b','c','d'];

julia> B = A[v]
4-element Vector{Char}:
 'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
 'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase)
 'c': ASCII/Unicode U+0063 (category Ll: Letter, lowercase)
 'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)

julia> B[invperm(v)]
4-element Vector{Char}:
 'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
 'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
 'c': ASCII/Unicode U+0063 (category Ll: Letter, lowercase)
 'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/combinatorics.jl#L239-L279)
```julia
isperm(v) -> Bool
```
Return `true` if `v` is a valid permutation.
**Examples**
```julia-repl
julia> isperm([1; 2])
true

julia> isperm([1; 3])
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/combinatorics.jl#L55-L68)
```julia
permute!(v, p)
```
Permute vector `v` in-place, according to permutation `p`. No checking is done to verify that `p` is a permutation.


## [Combinatorics](#Combinatorics)
To return a new permutation, use `v[p]`. This is generally faster than `permute!(v, p)`; it is even faster to write into a pre-allocated output array with `u .= @view v[p]`. (Even though `permute!` overwrites `v` in-place, it internally requires some allocation to keep track of which elements have been moved.)
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also [`invpermute!`](#Base.invpermute!).
**Examples**
```julia-repl
julia> A = [1, 1, 3, 4];

julia> perm = [2, 4, 3, 1];

julia> permute!(A, perm);

julia> A
4-element Vector{Int64}:
 1
 4
 3
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/combinatorics.jl#L177-L207)
```julia
invpermute!(v, p)
```
Like [`permute!`](#Base.permute!-Tuple%7BAny,%20AbstractVector%7D), but the inverse of the given permutation is applied.
Note that if you have a pre-allocated output array (e.g. `u = similar(v)`), it is quicker to instead employ `u[p] = v`. (`invpermute!` internally allocates a copy of the data.)
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> A = [1, 1, 3, 4];

julia> perm = [2, 4, 3, 1];

julia> invpermute!(A, perm);

julia> A
4-element Vector{Int64}:
 4
 1
 3
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/combinatorics.jl#L210-L236)
```julia
reverse(A; dims=:)
```


## [Combinatorics](#Combinatorics)
Reverse `A` along dimension `dims`, which can be an integer (a single dimension), a tuple of integers (a tuple of dimensions) or `:` (reverse along all the dimensions, the default). See also [`reverse!`](#Base.reverse!) for in-place reversal.
**Examples**
```julia-repl
julia> b = Int64[1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> reverse(b, dims=2)
2×2 Matrix{Int64}:
 2  1
 4  3

julia> reverse(b)
2×2 Matrix{Int64}:
 4  3
 2  1
```
Prior to Julia 1.6, only single-integer `dims` are supported in `reverse`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L30-L58)
```julia
reverseind(v, i)
```
Given an index `i` in [`reverse(v)`](#Base.reverse-Tuple%7BAbstractVector%7D), return the corresponding index in `v` so that `v[reverseind(v,i)] == reverse(v)[i]`. (This can be nontrivial in cases where `v` contains non-ASCII characters.)
**Examples**
```julia-repl
julia> s = "Julia🚀"
"Julia🚀"

julia> r = reverse(s)
"🚀ailuJ"

julia> for i in eachindex(s)
           print(r[reverseind(r, i)])
       end
Julia🚀
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L728-L748)
```julia
reverse!(v [, start=firstindex(v) [, stop=lastindex(v) ]]) -> v
```
In-place version of [`reverse`](#Base.reverse-Tuple%7BAbstractVector%7D).
**Examples**
```julia-repl
julia> A = Vector(1:5)
5-element Vector{Int64}:
 1
 2
 3
 4
 5

julia> reverse!(A);

julia> A
5-element Vector{Int64}:
 5
 4
 3
 2
 1
```


## [Combinatorics](#Combinatorics)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2164-L2189)
```julia
reverse!(A; dims=:)
```
Like [`reverse`](#Base.reverse-Tuple%7BAbstractVector%7D), but operates in-place in `A`.
Multidimensional `reverse!` requires Julia 1.6.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/arraymath.jl#L62-L69)
------------------------------------------------------------------------


# Tasks · The Julia Language
Source: https://docs.julialang.org/en/v1/base/parallel/


# [Tasks](#Tasks)
```julia
Task(func)
```
Create a `Task` (i.e. coroutine) to execute the given function `func` (which must be callable with no arguments). The task exits when this function returns. The task will run in the "world age" from the parent at construction when [`schedule`](#Base.schedule)d.
By default tasks will have the sticky bit set to true `t.sticky`. This models the historic default for [`@async`](#Base.@async). Sticky tasks can only be run on the worker thread they are first scheduled on, and when scheduled will make the task that they were scheduled from sticky. To obtain the behavior of [`Threads.@spawn`](../multi-threading/#Base.Threads.@spawn) set the sticky bit manually to `false`.
**Examples**
```julia-repl
julia> a() = sum(i for i in 1:1000);

julia> b = Task(a);
```
In this example, `b` is a runnable `Task` that hasn't started yet.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/docs/basedocs.jl#L1786-L1808)
```julia
@task
```
Wrap an expression in a [`Task`](#Core.Task) without executing it, and return the [`Task`](#Core.Task). This only creates a task, and does not run it.
By default tasks will have the sticky bit set to true `t.sticky`. This models the historic default for [`@async`](#Base.@async). Sticky tasks can only be run on the worker thread they are first scheduled on, and when scheduled will make the task that they were scheduled from sticky. To obtain the behavior of [`Threads.@spawn`](../multi-threading/#Base.Threads.@spawn) set the sticky bit manually to `false`.
**Examples**


# [Tasks](#Tasks)
```julia-repl
julia> a1() = sum(i for i in 1:1000);

julia> b = @task a1();

julia> istaskstarted(b)
false

julia> schedule(b);

julia> yield();

julia> istaskdone(b)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L112-L141)
```julia
@async
```
Wrap an expression in a [`Task`](#Core.Task) and add it to the local machine's scheduler queue.
Values can be interpolated into `@async` via `$`, which copies the value directly into the constructed underlying closure. This allows you to insert the *value* of a variable, isolating the asynchronous code from changes to the variable's value in the current task.
It is strongly encouraged to favor `Threads.@spawn` over `@async` always **even when no parallelism is required** especially in publicly distributed libraries. This is because a use of `@async` disables the migration of the *parent* task across worker threads in the current implementation of Julia. Thus, seemingly innocent use of `@async` in a library function can have a large impact on the performance of very different parts of user applications.
Interpolating values via `$` is available as of Julia 1.4.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L507-L526)
```julia
asyncmap(f, c...; ntasks=0, batch_size=nothing)
```
Uses multiple concurrent tasks to map `f` over a collection (or multiple equal length collections). For multiple collection arguments, `f` is applied elementwise.


# [Tasks](#Tasks)
`ntasks` specifies the number of tasks to run concurrently. Depending on the length of the collections, if `ntasks` is unspecified, up to 100 tasks will be used for concurrent mapping.
`ntasks` can also be specified as a zero-arg function. In this case, the number of tasks to run in parallel is checked before processing every element and a new task started if the value of `ntasks_func` is greater than the current number of tasks.
If `batch_size` is specified, the collection is processed in batch mode. `f` must then be a function that must accept a `Vector` of argument tuples and must return a vector of results. The input vector will have a length of `batch_size` or less.
The following examples highlight execution in different tasks by returning the `objectid` of the tasks in which the mapping function is executed.
First, with `ntasks` undefined, each element is processed in a different task.
```julia
julia> tskoid() = objectid(current_task());

julia> asyncmap(x->tskoid(), 1:5)
5-element Array{UInt64,1}:
 0x6e15e66c75c75853
 0x440f8819a1baa682
 0x9fb3eeadd0c83985
 0xebd3e35fe90d4050
 0x29efc93edce2b961

julia> length(unique(asyncmap(x->tskoid(), 1:5)))
5
```
With `ntasks=2` all elements are processed in 2 tasks.
```julia
julia> asyncmap(x->tskoid(), 1:5; ntasks=2)
5-element Array{UInt64,1}:
 0x027ab1680df7ae94
 0xa23d2f80cd7cf157
 0x027ab1680df7ae94
 0xa23d2f80cd7cf157
 0x027ab1680df7ae94

julia> length(unique(asyncmap(x->tskoid(), 1:5; ntasks=2)))
2
```


# [Tasks](#Tasks)
With `batch_size` defined, the mapping function needs to be changed to accept an array of argument tuples and return an array of results. `map` is used in the modified mapping function to achieve this.
```julia
julia> batch_func(input) = map(x->string("args_tuple: ", x, ", element_val: ", x[1], ", task: ", tskoid()), input)
batch_func (generic function with 1 method)

julia> asyncmap(batch_func, 1:5; ntasks=2, batch_size=2)
5-element Array{String,1}:
 "args_tuple: (1,), element_val: 1, task: 9118321258196414413"
 "args_tuple: (2,), element_val: 2, task: 4904288162898683522"
 "args_tuple: (3,), element_val: 3, task: 9118321258196414413"
 "args_tuple: (4,), element_val: 4, task: 4904288162898683522"
 "args_tuple: (5,), element_val: 5, task: 9118321258196414413"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/asyncmap.jl#L5-L73)
```julia
asyncmap!(f, results, c...; ntasks=0, batch_size=nothing)
```
Like [`asyncmap`](#Base.asyncmap), but stores output in `results` rather than returning a collection.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/asyncmap.jl#L392-L399)
```julia
current_task()
```
Get the currently running [`Task`](#Core.Task).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L147-L151)
```julia
istaskdone(t::Task) -> Bool
```
Determine whether a task has exited.
**Examples**


# [Tasks](#Tasks)
```julia-repl
julia> a2() = sum(i for i in 1:1000);

julia> b = Task(a2);

julia> istaskdone(b)
false

julia> schedule(b);

julia> yield();

julia> istaskdone(b)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L204-L225)
```julia
istaskstarted(t::Task) -> Bool
```
Determine whether a task has started executing.
**Examples**
```julia-repl
julia> a3() = sum(i for i in 1:1000);

julia> b = Task(a3);

julia> istaskstarted(b)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L228-L242)
```julia
istaskfailed(t::Task) -> Bool
```
Determine whether a task has exited because an exception was thrown.
**Examples**
```julia-repl
julia> a4() = error("task failed");

julia> b = Task(a4);

julia> istaskfailed(b)
false

julia> schedule(b);

julia> yield();

julia> istaskfailed(b)
true
```
This function requires at least Julia 1.3.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L245-L269)
```julia
task_local_storage(key)
```
Look up the value of a key in the current task's task-local storage.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L288-L292)
```julia
task_local_storage(key, value)
```
Assign a value to a key in the current task's task-local storage.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L295-L299)
```julia
task_local_storage(body, key, value)
```


# [Tasks](#Tasks)
Call the function `body` with a modified task-local storage, in which `value` is assigned to `key`; the previous value of `key`, or lack thereof, is restored afterwards. Useful for emulating dynamic scoping.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L302-L308)


## [Scheduling](#Scheduling)
```julia
yield()
```
Switch to the scheduler to allow another scheduled task to run. A task that calls this function is still runnable, and will be restarted immediately if there are no other runnable tasks.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L891-L897)
```julia
yield(t::Task, arg = nothing)
```
A fast, unfair-scheduling version of `schedule(t, arg); yield()` which immediately yields to `t` before calling the scheduler.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L911-L916)
```julia
yieldto(t::Task, arg = nothing)
```
Switch to the given task. The first time a task is switched to, the task's function is called with no arguments. On subsequent switches, `arg` is returned from the task's last call to `yieldto`. This is a low-level call that only switches tasks, not considering states or scheduling in any way. Its use is discouraged.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/task.jl#L925-L932)
```julia
sleep(seconds)
```
Block the current task for a specified number of seconds. The minimum sleep time is 1 millisecond or input of `0.001`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/asyncevent.jl#L264-L269)
```julia
schedule(t::Task, [val]; error=false)
```