## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> extrema(sin, 0:π)
(0.0, 0.9092974268256817)

julia> extrema(sin, Real[]; init = (1.0, -1.0))  # good, since -1 ≤ sin(::Real) ≤ 1
(1.0, -1.0)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L824-L851)
```julia
extrema(A::AbstractArray; dims) -> Array{Tuple}
```
Compute the minimum and maximum elements of an array over the given dimensions.
See also: [`minimum`](#Base.minimum), [`maximum`](#Base.maximum), [`extrema!`](#Base.extrema!).
**Examples**
```julia-repl
julia> A = reshape(Vector(1:2:16), (2,2,2))
2×2×2 Array{Int64, 3}:
[:, :, 1] =
 1  5
 3  7

[:, :, 2] =
  9  13
 11  15

julia> extrema(A, dims = (1,2))
1×1×2 Array{Tuple{Int64, Int64}, 3}:
[:, :, 1] =
 (1, 7)

[:, :, 2] =
 (9, 15)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L757-L784)
```julia
extrema(f, A::AbstractArray; dims) -> Array{Tuple}
```
Compute the minimum and maximum of `f` applied to each element in the given dimensions of `A`.
This method requires Julia 1.2 or later.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L787-L795)
```julia
extrema!(r, A)
```
Compute the minimum and maximum value of `A` over the singleton dimensions of `r`, and write results to `r`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
This method requires Julia 1.8 or later.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> extrema!([(1, 1); (1, 1)], A)
2-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (3, 4)

julia> extrema!([(1, 1);; (1, 1)], A)
1×2 Matrix{Tuple{Int64, Int64}}:
 (1, 3)  (2, 4)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L798-L824)
```julia
argmax(r::AbstractRange)
```
Ranges can have multiple maximal elements. In that case `argmax` will return a maximal index, but not necessarily the first one.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L872-L878)
```julia
argmax(f, domain)
```
Return a value `x` from `domain` for which `f(x)` is maximised. If there are multiple maximal values for `f(x)` then the first one will be found.
`domain` must be a non-empty iterable.
Values are compared with `isless`.
This method requires Julia 1.7 or later.
See also [`argmin`](#Base.argmin), [`findmax`](#Base.findmax).
**Examples**
```julia-repl
julia> argmax(abs, -10:5)
-10

julia> argmax(cos, 0:π/2:2π)
0.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1003-L1026)
```julia
argmax(itr)
```
Return the index or key of the maximal element in a collection. If there are multiple maximal elements, then the first one will be returned.
The collection must not be empty.


## [Iterable Collections](#Iterable-Collections)
Indices are of the same type as those returned by [`keys(itr)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(itr)`](#Base.pairs).
Values are compared with `isless`.
See also: [`argmin`](#Base.argmin), [`findmax`](#Base.findmax).
**Examples**
```julia-repl
julia> argmax([8, 0.1, -9, pi])
1

julia> argmax([1, 7, 7, 6])
2

julia> argmax([1, 7, 7, NaN])
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1029-L1055)
```julia
argmax(A; dims) -> indices
```
For an array input, return the indices of the maximum elements over the given dimensions. `NaN` is treated as greater than all other values except `missing`.
**Examples**
```julia-repl
julia> A = [1.0 2; 3 4]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> argmax(A, dims=1)
1×2 Matrix{CartesianIndex{2}}:
 CartesianIndex(2, 1)  CartesianIndex(2, 2)

julia> argmax(A, dims=2)
2×1 Matrix{CartesianIndex{2}}:
 CartesianIndex(1, 2)
 CartesianIndex(2, 2)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1251-L1273)
```julia
argmin(r::AbstractRange)
```
Ranges can have multiple minimal elements. In that case `argmin` will return a minimal index, but not necessarily the first one.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L855-L861)
```julia
argmin(f, domain)
```


## [Iterable Collections](#Iterable-Collections)
Return a value `x` from `domain` for which `f(x)` is minimised. If there are multiple minimal values for `f(x)` then the first one will be found.
`domain` must be a non-empty iterable.
`NaN` is treated as less than all other values except `missing`.
This method requires Julia 1.7 or later.
See also [`argmax`](#Base.argmax), [`findmin`](#Base.findmin).
**Examples**
```julia-repl
julia> argmin(sign, -10:5)
-10

julia> argmin(x -> -x^3 + x^2 - 10, -5:5)
5

julia> argmin(acos, 0:0.1:1)
1.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1058-L1084)
```julia
argmin(itr)
```
Return the index or key of the minimal element in a collection. If there are multiple minimal elements, then the first one will be returned.
The collection must not be empty.
Indices are of the same type as those returned by [`keys(itr)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(itr)`](#Base.pairs).
`NaN` is treated as less than all other values except `missing`.
See also: [`argmax`](#Base.argmax), [`findmin`](#Base.findmin).
**Examples**
```julia-repl
julia> argmin([8, 0.1, -9, pi])
3

julia> argmin([7, 1, 1, 6])
2

julia> argmin([7, 1, 1, NaN])
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1087-L1113)
```julia
argmin(A; dims) -> indices
```
For an array input, return the indices of the minimum elements over the given dimensions. `NaN` is treated as less than all other values except `missing`.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [1.0 2; 3 4]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> argmin(A, dims=1)
1×2 Matrix{CartesianIndex{2}}:
 CartesianIndex(1, 1)  CartesianIndex(1, 2)

julia> argmin(A, dims=2)
2×1 Matrix{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1226-L1248)
```julia
findmax(f, domain) -> (f(x), index)
```
Return a pair of a value in the codomain (outputs of `f`) and the index or key of the corresponding value in the `domain` (inputs to `f`) such that `f(x)` is maximised. If there are multiple maximal points, then the first one will be returned.
`domain` must be a non-empty iterable supporting [`keys`](#Base.keys). Indices are of the same type as those returned by [`keys(domain)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D).
Values are compared with `isless`.
This method requires Julia 1.7 or later.
**Examples**
```julia-repl
julia> findmax(identity, 5:9)
(9, 5)

julia> findmax(-, 1:10)
(-1, 1)

julia> findmax(first, [(1, :a), (3, :b), (3, :c)])
(3, 2)

julia> findmax(cos, 0:π/2:2π)
(1.0, 1)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L874-L904)
```julia
findmax(itr) -> (x, index)
```
Return the maximal element of the collection `itr` and its index or key. If there are multiple maximal elements, then the first one will be returned. Values are compared with `isless`.


## [Iterable Collections](#Iterable-Collections)
Indices are of the same type as those returned by [`keys(itr)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(itr)`](#Base.pairs).
See also: [`findmin`](#Base.findmin), [`argmax`](#Base.argmax), [`maximum`](#Base.maximum).
**Examples**
```julia-repl
julia> findmax([8, 0.1, -9, pi])
(8.0, 1)

julia> findmax([1, 7, 7, 6])
(7, 2)

julia> findmax([1, 7, 7, NaN])
(NaN, 4)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L909-L933)
```julia
findmax(A; dims) -> (maxval, index)
```
For an array input, returns the value and index of the maximum over the given dimensions. `NaN` is treated as greater than all other values except `missing`.
**Examples**
```julia-repl
julia> A = [1.0 2; 3 4]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> findmax(A, dims=1)
([3.0 4.0], CartesianIndex{2}[CartesianIndex(2, 1) CartesianIndex(2, 2)])

julia> findmax(A, dims=2)
([2.0; 4.0;;], CartesianIndex{2}[CartesianIndex(1, 2); CartesianIndex(2, 2);;])
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1155-L1174)
```julia
findmax(f, A; dims) -> (f(x), index)
```
For an array input, returns the value in the codomain and index of the corresponding value which maximize `f` over the given dimensions.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [-1.0 1; -0.5 2]
2×2 Matrix{Float64}:
 -1.0  1.0
 -0.5  2.0

julia> findmax(abs2, A, dims=1)
([1.0 4.0], CartesianIndex{2}[CartesianIndex(1, 1) CartesianIndex(2, 2)])

julia> findmax(abs2, A, dims=2)
([1.0; 4.0;;], CartesianIndex{2}[CartesianIndex(1, 1); CartesianIndex(2, 2);;])
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1178-L1197)
```julia
findmin(f, domain) -> (f(x), index)
```
Return a pair of a value in the codomain (outputs of `f`) and the index or key of the corresponding value in the `domain` (inputs to `f`) such that `f(x)` is minimised. If there are multiple minimal points, then the first one will be returned.
`domain` must be a non-empty iterable.
Indices are of the same type as those returned by [`keys(domain)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(domain)`](#Base.pairs).
`NaN` is treated as less than all other values except `missing`.
This method requires Julia 1.7 or later.
**Examples**
```julia-repl
julia> findmin(identity, 5:9)
(5, 1)

julia> findmin(-, 1:10)
(-10, 10)

julia> findmin(first, [(2, :a), (2, :b), (3, :c)])
(2, 1)

julia> findmin(cos, 0:π/2:2π)
(-1.0, 3)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L937-L970)
```julia
findmin(itr) -> (x, index)
```


## [Iterable Collections](#Iterable-Collections)
Return the minimal element of the collection `itr` and its index or key. If there are multiple minimal elements, then the first one will be returned. `NaN` is treated as less than all other values except `missing`.
Indices are of the same type as those returned by [`keys(itr)`](../arrays/#Base.keys-Tuple%7BAbstractArray%7D) and [`pairs(itr)`](#Base.pairs).
See also: [`findmax`](#Base.findmax), [`argmin`](#Base.argmin), [`minimum`](#Base.minimum).
**Examples**
```julia-repl
julia> findmin([8, 0.1, -9, pi])
(-9.0, 3)

julia> findmin([1, 7, 7, 6])
(1, 1)

julia> findmin([1, 7, 7, NaN])
(NaN, 4)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L975-L999)
```julia
findmin(A; dims) -> (minval, index)
```
For an array input, returns the value and index of the minimum over the given dimensions. `NaN` is treated as less than all other values except `missing`.
**Examples**
```julia-repl
julia> A = [1.0 2; 3 4]
2×2 Matrix{Float64}:
 1.0  2.0
 3.0  4.0

julia> findmin(A, dims=1)
([1.0 2.0], CartesianIndex{2}[CartesianIndex(1, 1) CartesianIndex(1, 2)])

julia> findmin(A, dims=2)
([1.0; 3.0;;], CartesianIndex{2}[CartesianIndex(1, 1); CartesianIndex(2, 1);;])
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1082-L1101)
```julia
findmin(f, A; dims) -> (f(x), index)
```
For an array input, returns the value in the codomain and index of the corresponding value which minimize `f` over the given dimensions.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [-1.0 1; -0.5 2]
2×2 Matrix{Float64}:
 -1.0  1.0
 -0.5  2.0

julia> findmin(abs2, A, dims=1)
([0.25 1.0], CartesianIndex{2}[CartesianIndex(2, 1) CartesianIndex(1, 2)])

julia> findmin(abs2, A, dims=2)
([1.0; 0.25;;], CartesianIndex{2}[CartesianIndex(1, 1); CartesianIndex(2, 1);;])
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1105-L1124)
```julia
findmax!(rval, rind, A) -> (maxval, index)
```
Find the maximum of `A` and the corresponding linear index along singleton dimensions of `rval` and `rind`, and store the results in `rval` and `rind`. `NaN` is treated as greater than all other values except `missing`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1141-L1149)
```julia
findmin!(rval, rind, A) -> (minval, index)
```
Find the minimum of `A` and the corresponding linear index along singleton dimensions of `rval` and `rind`, and store the results in `rval` and `rind`. `NaN` is treated as less than all other values except `missing`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L1068-L1076)
```julia
sum(f, itr; [init])
```
Sum the results of calling function `f` on each element of `itr`.


## [Iterable Collections](#Iterable-Collections)
The return type is `Int` for signed integers of less than system word size, and `UInt` for unsigned integers of less than system word size. For all other arguments, a common return type is found to which all arguments are promoted.
The value returned for empty `itr` can be specified by `init`. It must be the additive identity (i.e. zero) as it is unspecified whether `init` is used for non-empty collections.
Keyword argument `init` requires Julia 1.6 or later.
**Examples**
```julia-repl
julia> sum(abs2, [2; 3; 4])
29
```
Note the important difference between `sum(A)` and `reduce(+, A)` for arrays with small integer eltype:
```julia-repl
julia> sum(Int8[100, 28])
128

julia> reduce(+, Int8[100, 28])
-128
```
In the former case, the integers are widened to system word size and therefore the result is 128. In the latter case, no such widening happens and integer overflow results in -128.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L495-L531)
```julia
sum(itr; [init])
```
Return the sum of all elements in a collection.
The return type is `Int` for signed integers of less than system word size, and `UInt` for unsigned integers of less than system word size. For all other arguments, a common return type is found to which all arguments are promoted.
The value returned for empty `itr` can be specified by `init`. It must be the additive identity (i.e. zero) as it is unspecified whether `init` is used for non-empty collections.


## [Iterable Collections](#Iterable-Collections)
Keyword argument `init` requires Julia 1.6 or later.
See also: [`reduce`](#Base.reduce-Tuple%7BAny,%20Any%7D), [`mapreduce`](#Base.mapreduce-Tuple%7BAny,%20Any,%20Any%7D), [`count`](#Base.count), [`union`](#Base.union).
**Examples**
```julia-repl
julia> sum(1:20)
210

julia> sum(1:20; init = 0.0)
210.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L534-L560)
```julia
sum(A::AbstractArray; dims)
```
Sum elements of an array over the given dimensions.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> sum(A, dims=1)
1×2 Matrix{Int64}:
 4  6

julia> sum(A, dims=2)
2×1 Matrix{Int64}:
 3
 7
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L449-L470)
```julia
sum(f, A::AbstractArray; dims)
```
Sum the results of calling function `f` on each element of an array over the given dimensions.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> sum(abs2, A, dims=1)
1×2 Matrix{Int64}:
 10  20

julia> sum(abs2, A, dims=2)
2×1 Matrix{Int64}:
  5
 25
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L473-L495)
```julia
sum!(r, A)
```
Sum elements of `A` over the singleton dimensions of `r`, and write results to `r`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> sum!([1; 1], A)
2-element Vector{Int64}:
 3
 7

julia> sum!([1 1], A)
1×2 Matrix{Int64}:
 4  6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L498-L521)
```julia
prod(f, itr; [init])
```
Return the product of `f` applied to each element of `itr`.
The return type is `Int` for signed integers of less than system word size, and `UInt` for unsigned integers of less than system word size. For all other arguments, a common return type is found to which all arguments are promoted.
The value returned for empty `itr` can be specified by `init`. It must be the multiplicative identity (i.e. one) as it is unspecified whether `init` is used for non-empty collections.
Keyword argument `init` requires Julia 1.6 or later.
**Examples**
```julia-repl
julia> prod(abs2, [2; 3; 4])
576
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L566-L587)
```julia
prod(itr; [init])
```
Return the product of all elements of a collection.
The return type is `Int` for signed integers of less than system word size, and `UInt` for unsigned integers of less than system word size. For all other arguments, a common return type is found to which all arguments are promoted.
The value returned for empty `itr` can be specified by `init`. It must be the multiplicative identity (i.e. one) as it is unspecified whether `init` is used for non-empty collections.


## [Iterable Collections](#Iterable-Collections)
Keyword argument `init` requires Julia 1.6 or later.
See also: [`reduce`](#Base.reduce-Tuple%7BAny,%20Any%7D), [`cumprod`](../arrays/#Base.cumprod), [`any`](#Base.any-Tuple%7BAny%7D).
**Examples**
```julia-repl
julia> prod(1:5)
120

julia> prod(1:5; init = 1.0)
120.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L590-L616)
```julia
prod(A::AbstractArray; dims)
```
Multiply elements of an array over the given dimensions.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> prod(A, dims=1)
1×2 Matrix{Int64}:
 3  8

julia> prod(A, dims=2)
2×1 Matrix{Int64}:
  2
 12
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L524-L545)
```julia
prod(f, A::AbstractArray; dims)
```
Multiply the results of calling the function `f` on each element of an array over the given dimensions.
**Examples**
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> prod(abs2, A, dims=1)
1×2 Matrix{Int64}:
 9  64

julia> prod(abs2, A, dims=2)
2×1 Matrix{Int64}:
   4
 144
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L548-L570)
```julia
prod!(r, A)
```
Multiply elements of `A` over the singleton dimensions of `r`, and write results to `r`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> prod!([1; 1], A)
2-element Vector{Int64}:
  2
 12

julia> prod!([1 1], A)
1×2 Matrix{Int64}:
 3  8
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L573-L596)
```julia
any(itr) -> Bool
```
Test whether any elements of a boolean collection are `true`, returning `true` as soon as the first `true` value in `itr` is encountered (short-circuiting). To short-circuit on `false`, use [`all`](#Base.all-Tuple%7BAny%7D).
If the input contains [`missing`](../../manual/missing/#missing) values, return `missing` if all non-missing values are `false` (or equivalently, if the input contains no `true` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic).
See also: [`all`](#Base.all-Tuple%7BAny%7D), [`count`](#Base.count), [`sum`](#Base.sum), [`|`](../math/#Base.:%7C), , [`||`](../math/#%7C%7C).
**Examples**
```julia-repl
julia> a = [true,false,false,true]
4-element Vector{Bool}:
 1
 0
 0
 1

julia> any(a)
true

julia> any((println(i); v) for (i, v) in enumerate(a))
1
true

julia> any([missing, true])
true

julia> any([false, missing])
missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1118-L1153)
```julia
any(p, itr) -> Bool
```


## [Iterable Collections](#Iterable-Collections)
Determine whether predicate `p` returns `true` for any elements of `itr`, returning `true` as soon as the first item in `itr` for which `p` returns `true` is encountered (short-circuiting). To short-circuit on `false`, use [`all`](#Base.all-Tuple%7BAny%7D).
If the input contains [`missing`](../../manual/missing/#missing) values, return `missing` if all non-missing values are `false` (or equivalently, if the input contains no `true` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic).
**Examples**
```julia-repl
julia> any(i->(4<=i<=6), [3,5,7])
true

julia> any(i -> (println(i); i > 3), 1:10)
1
2
3
4
true

julia> any(i -> i > 0, [1, missing])
true

julia> any(i -> i > 0, [-1, missing])
missing

julia> any(i -> i > 0, [-1, 0])
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1195-L1227)
```julia
any!(r, A)
```
Test whether any values in `A` along the singleton dimensions of `r` are `true`, and write results to `r`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> A = [true false; true false]
2×2 Matrix{Bool}:
 1  0
 1  0

julia> any!([1; 1], A)
2-element Vector{Int64}:
 1
 1

julia> any!([1 1], A)
1×2 Matrix{Int64}:
 1  0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L949-L973)
```julia
all(itr) -> Bool
```


## [Iterable Collections](#Iterable-Collections)
Test whether all elements of a boolean collection are `true`, returning `false` as soon as the first `false` value in `itr` is encountered (short-circuiting). To short-circuit on `true`, use [`any`](#Base.any-Tuple%7BAny%7D).
If the input contains [`missing`](../../manual/missing/#missing) values, return `missing` if all non-missing values are `true` (or equivalently, if the input contains no `false` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic).
See also: [`all!`](#Base.all!), [`any`](#Base.any-Tuple%7BAny%7D), [`count`](#Base.count), [`&`](../math/#Base.:&), , [`&&`](../math/#&&), [`allunique`](#Base.allunique).
**Examples**
```julia-repl
julia> a = [true,false,false,true]
4-element Vector{Bool}:
 1
 0
 0
 1

julia> all(a)
false

julia> all((println(i); v) for (i, v) in enumerate(a))
1
2
false

julia> all([missing, false])
false

julia> all([true, missing])
missing
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1156-L1192)
```julia
all(p, itr) -> Bool
```
Determine whether predicate `p` returns `true` for all elements of `itr`, returning `false` as soon as the first item in `itr` for which `p` returns `false` is encountered (short-circuiting). To short-circuit on `true`, use [`any`](#Base.any-Tuple%7BAny%7D).


## [Iterable Collections](#Iterable-Collections)
If the input contains [`missing`](../../manual/missing/#missing) values, return `missing` if all non-missing values are `true` (or equivalently, if the input contains no `false` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic).
**Examples**
```julia-repl
julia> all(i->(4<=i<=6), [4,5,6])
true

julia> all(i -> (println(i); i < 3), 1:10)
1
2
3
false

julia> all(i -> i > 0, [1, missing])
missing

julia> all(i -> i > 0, [-1, missing])
false

julia> all(i -> i > 0, [1, 2])
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1269-L1300)
```julia
all!(r, A)
```
Test whether all values in `A` along the singleton dimensions of `r` are `true`, and write results to `r`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> A = [true false; true false]
2×2 Matrix{Bool}:
 1  0
 1  0

julia> all!([1; 1], A)
2-element Vector{Int64}:
 0
 0

julia> all!([1 1], A)
1×2 Matrix{Int64}:
 1  0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L875-L898)
```julia
count([f=identity,] itr; init=0) -> Integer
```
Count the number of elements in `itr` for which the function `f` returns `true`. If `f` is omitted, count the number of `true` elements in `itr` (which should be a collection of boolean values). `init` optionally specifies the value to start counting from and therefore also determines the output type.


## [Iterable Collections](#Iterable-Collections)
`init` keyword was added in Julia 1.6.
See also: [`any`](#Base.any-Tuple%7BAny%7D), [`sum`](#Base.sum).
**Examples**
```julia-repl
julia> count(i->(4<=i<=6), [2,3,4,5,6])
3

julia> count([true, false, true, true])
3

julia> count(>(3), 1:7, init=0x03)
0x07
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L1348-L1372)
```julia
count(
    pattern::Union{AbstractChar,AbstractString,AbstractPattern},
    string::AbstractString;
    overlap::Bool = false,
)
```
Return the number of matches for `pattern` in `string`. This is equivalent to calling `length(findall(pattern, string))` but more efficient.
If `overlap=true`, the matching sequences are allowed to overlap indices in the original string, otherwise they must be from disjoint character ranges.
This method requires at least Julia 1.3.
Using a character as the pattern requires at least Julia 1.7.
**Examples**
```julia-repl
julia> count('a', "JuliaLang")
2

julia> count(r"a(.)a", "cabacabac", overlap=true)
3

julia> count(r"a(.)a", "cabacabac")
2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/regex.jl#L519-L549)
```julia
count([f=identity,] A::AbstractArray; dims=:)
```
Count the number of elements in `A` for which `f` returns `true` over the given dimensions.
`dims` keyword was added in Julia 1.5.
`init` keyword was added in Julia 1.6.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> count(<=(2), A, dims=1)
1×2 Matrix{Int64}:
 1  1

julia> count(<=(2), A, dims=2)
2×1 Matrix{Int64}:
 2
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reducedim.jl#L382-L410)
```julia
foreach(f, c...) -> Nothing
```
Call function `f` on each element of iterable `c`. For multiple iterable arguments, `f` is called elementwise, and iteration stops when any iterator is finished.
`foreach` should be used instead of [`map`](#Base.map) when the results of `f` are not needed, for example in `foreach(println, array)`.
**Examples**
```julia-repl
julia> tri = 1:3:7; res = Int[];

julia> foreach(x -> push!(res, x^2), tri)

julia> res
3-element Vector{Int64}:
  1
 16
 49

julia> foreach((x, y) -> println(x, " with ", y), tri, 'a':'z')
1 with a
4 with b
7 with c
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3159-L3186)
```julia
map(f, c...) -> collection
```
Transform collection `c` by applying `f` to each element. For multiple collection arguments, apply `f` elementwise, and stop when any of them is exhausted.
See also [`map!`](#Base.map!), [`foreach`](#Base.foreach), [`mapreduce`](#Base.mapreduce-Tuple%7BAny,%20Any,%20Any%7D), [`mapslices`](../arrays/#Base.mapslices), [`zip`](../iterators/#Base.Iterators.zip), [`Iterators.map`](../iterators/#Base.Iterators.map).
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> map(x -> x * 2, [1, 2, 3])
3-element Vector{Int64}:
 2
 4
 6

julia> map(+, [1, 2, 3], [10, 20, 30, 400, 5000])
3-element Vector{Int64}:
 11
 22
 33
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3376-L3398)
```julia
map(f, A::AbstractArray...) -> N-array
```
When acting on multi-dimensional arrays of the same [`ndims`](../arrays/#Base.ndims), they must all have the same [`axes`](../arrays/#Base.axes-Tuple%7BAny%7D), and the answer will too.
See also [`broadcast`](../arrays/#Base.Broadcast.broadcast), which allows mismatched sizes.
**Examples**
```julia
julia> map(//, [1 2; 3 4], [4 3; 2 1])
2×2 Matrix{Rational{Int64}}:
 1//4  2//3
 3//2  4//1

julia> map(+, [1 2; 3 4], zeros(2,1))
ERROR: DimensionMismatch

julia> map(+, [1 2; 3 4], [1,10,100,1000], zeros(3,1))  # iterates until 3rd is exhausted
3-element Vector{Float64}:
   2.0
  13.0
 102.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3477-L3501)
```julia
map!(function, destination, collection...)
```
Like [`map`](#Base.map), but stores the result in `destination` rather than a new collection. `destination` must be at least as large as the smallest collection.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
See also: [`map`](#Base.map), [`foreach`](#Base.foreach), [`zip`](../iterators/#Base.Iterators.zip), [`copyto!`](../c/#Base.copyto!).
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> a = zeros(3);

julia> map!(x -> x * 2, a, [1, 2, 3]);

julia> a
3-element Vector{Float64}:
 2.0
 4.0
 6.0

julia> map!(+, zeros(Int, 5), 100:999, 1:3)
5-element Vector{Int64}:
 101
 103
 105
   0
   0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L3440-L3470)
```julia
map!(f, values(dict::AbstractDict))
```
Modifies `dict` by transforming each value from `val` to `f(val)`. Note that the type of `dict` cannot be changed: if `f(val)` is not an instance of the value type of `dict` then it will be converted to the value type if possible and otherwise raise an error.
`map!(f, values(dict::AbstractDict))` requires Julia 1.2 or later.
**Examples**
```julia-repl
julia> d = Dict(:a => 1, :b => 2)
Dict{Symbol, Int64} with 2 entries:
  :a => 1
  :b => 2

julia> map!(v -> v-1, values(d))
ValueIterator for a Dict{Symbol, Int64} with 2 entries. Values:
  0
  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L648-L670)
```julia
mapreduce(f, op, itrs...; [init])
```
Apply function `f` to each element(s) in `itrs`, and then reduce the result using the binary function `op`. If provided, `init` must be a neutral element for `op` that will be returned for empty collections. It is unspecified whether `init` is used for non-empty collections. In general, it will be necessary to provide `init` to work with empty collections.


## [Iterable Collections](#Iterable-Collections)
[`mapreduce`](#Base.mapreduce-Tuple%7BAny,%20Any,%20Any%7D) is functionally equivalent to calling `reduce(op, map(f, itr); init=init)`, but will in general execute faster since no intermediate collection needs to be created. See documentation for [`reduce`](#Base.reduce-Tuple%7BAny,%20Any%7D) and [`map`](#Base.map).
`mapreduce` with multiple iterators requires Julia 1.2 or later.
**Examples**
```julia-repl
julia> mapreduce(x->x^2, +, [1:3;]) # == 1 + 4 + 9
14
```
The associativity of the reduction is implementation-dependent. Additionally, some implementations may reuse the return value of `f` for elements that appear multiple times in `itr`. Use [`mapfoldl`](#Base.mapfoldl-Tuple%7BAny,%20Any,%20Any%7D) or [`mapfoldr`](#Base.mapfoldr-Tuple%7BAny,%20Any,%20Any%7D) instead for guaranteed left or right associativity and invocation of `f` for every value.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L280-L306)
```julia
mapfoldl(f, op, itr; [init])
```
Like [`mapreduce`](#Base.mapreduce-Tuple%7BAny,%20Any,%20Any%7D), but with guaranteed left associativity, as in [`foldl`](#Base.foldl-Tuple%7BAny,%20Any%7D). If provided, the keyword argument `init` will be used exactly once. In general, it will be necessary to provide `init` to work with empty collections.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L168-L174)
```julia
mapfoldr(f, op, itr; [init])
```


## [Iterable Collections](#Iterable-Collections)
Like [`mapreduce`](#Base.mapreduce-Tuple%7BAny,%20Any,%20Any%7D), but with guaranteed right associativity, as in [`foldr`](#Base.foldr-Tuple%7BAny,%20Any%7D). If provided, the keyword argument `init` will be used exactly once. In general, it will be necessary to provide `init` to work with empty collections.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/reduce.jl#L216-L222)
```julia
first(coll)
```
Get the first element of an iterable collection. Return the start point of an [`AbstractRange`](#Base.AbstractRange) even if it is empty.
See also: [`only`](../iterators/#Base.Iterators.only), [`firstindex`](#Base.firstindex), [`last`](#Base.last).
**Examples**
```julia-repl
julia> first(2:2:10)
2

julia> first([1; 2; 3; 4])
1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L454-L470)
```julia
first(itr, n::Integer)
```
Get the first `n` elements of the iterable collection `itr`, or fewer elements if `itr` is not long enough.
See also: [`startswith`](../strings/#Base.startswith), [`Iterators.take`](../iterators/#Base.Iterators.take).
This method requires at least Julia 1.6.
**Examples**
```julia-repl
julia> first(["foo", "bar", "qux"], 2)
2-element Vector{String}:
 "foo"
 "bar"

julia> first(1:6, 10)
1:6

julia> first(Bool[], 1)
Bool[]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L477-L501)
```julia
first(s::AbstractString, n::Integer)
```


## [Iterable Collections](#Iterable-Collections)
Get a string consisting of the first `n` characters of `s`.
**Examples**
```julia-repl
julia> first("∀ϵ≠0: ϵ²>0", 0)
""

julia> first("∀ϵ≠0: ϵ²>0", 1)
"∀"

julia> first("∀ϵ≠0: ϵ²>0", 3)
"∀ϵ≠"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L690-L706)
```julia
last(coll)
```
Get the last element of an ordered collection, if it can be computed in O(1) time. This is accomplished by calling [`lastindex`](#Base.lastindex) to get the last index. Return the end point of an [`AbstractRange`](#Base.AbstractRange) even if it is empty.
See also [`first`](#Base.first), [`endswith`](../strings/#Base.endswith).
**Examples**
```julia-repl
julia> last(1:2:10)
9

julia> last([1; 2; 3; 4])
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L509-L526)
```julia
last(itr, n::Integer)
```
Get the last `n` elements of the iterable collection `itr`, or fewer elements if `itr` is not long enough.
This method requires at least Julia 1.6.
**Examples**
```julia-repl
julia> last(["foo", "bar", "qux"], 2)
2-element Vector{String}:
 "bar"
 "qux"

julia> last(1:6, 10)
1:6

julia> last(Float64[], 1)
Float64[]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L529-L551)
```julia
last(s::AbstractString, n::Integer)
```
Get a string consisting of the last `n` characters of `s`.
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> last("∀ϵ≠0: ϵ²>0", 0)
""

julia> last("∀ϵ≠0: ϵ²>0", 1)
"0"

julia> last("∀ϵ≠0: ϵ²>0", 3)
"²>0"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/strings/basic.jl#L709-L725)
```julia
front(x::Tuple)::Tuple
```
Return a `Tuple` consisting of all but the last component of `x`.
See also: [`first`](#Base.first), [`tail`](#Base.tail).
**Examples**
```julia-repl
julia> Base.front((1,2,3))
(1, 2)

julia> Base.front(())
ERROR: ArgumentError: Cannot call front on an empty tuple.
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L324-L339)
```julia
tail(x::Tuple)::Tuple
```
Return a `Tuple` consisting of all but the first component of `x`.
See also: [`front`](#Base.front), [`rest`](#Base.rest), [`first`](#Base.first), [`Iterators.peel`](../iterators/#Base.Iterators.peel).
**Examples**
```julia-repl
julia> Base.tail((1,2,3))
(2, 3)

julia> Base.tail(())
ERROR: ArgumentError: Cannot call tail on an empty tuple.
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L498-L513)
```julia
step(r)
```
Get the step size of an [`AbstractRange`](#Base.AbstractRange) object.
**Examples**
```julia-repl
julia> step(1:10)
1

julia> step(1:2:10)
2

julia> step(2.5:0.3:10.9)
0.3

julia> step(range(2.5, stop=10.9, length=85))
0.1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/range.jl#L685-L704)


## [Iterable Collections](#Iterable-Collections)
```julia
collect(collection)
```
Return an `Array` of all items in a collection or iterator. For dictionaries, returns a `Vector` of `key=>value` [Pair](#Core.Pair)s. If the argument is array-like or is an iterator with the [`HasShape`](#Base.IteratorSize) trait, the result will have the same shape and number of dimensions as the argument.
Used by [comprehensions](../../manual/arrays/#man-comprehensions) to turn a [generator expression](../../manual/arrays/#man-generators) into an `Array`. Thus, *on generators*, the square-brackets notation may be used instead of calling `collect`, see second example.
**Examples**
Collect items from a `UnitRange{Int64}` collection:
```julia-repl
julia> collect(1:3)
3-element Vector{Int64}:
 1
 2
 3
```
Collect items from a generator (same output as `[x^2 for x in 1:3]`):
```julia-repl
julia> collect(x^2 for x in 1:3)
3-element Vector{Int64}:
 1
 4
 9
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L682-L715)
```julia
collect(element_type, collection)
```
Return an `Array` with the given element type of all items in a collection or iterable. The result has the same shape and number of dimensions as `collection`.
**Examples**
```julia-repl
julia> collect(Float64, 1:2:5)
3-element Vector{Float64}:
 1.0
 3.0
 5.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L632-L646)
```julia
filter(f, a)
```


## [Iterable Collections](#Iterable-Collections)
Return a copy of collection `a`, removing elements for which `f` is `false`. The function `f` is passed one argument.
Support for `a` as a tuple requires at least Julia 1.4.
See also: [`filter!`](#Base.filter!), [`Iterators.filter`](../iterators/#Base.Iterators.filter).
**Examples**
```julia-repl
julia> a = 1:10
1:10

julia> filter(isodd, a)
5-element Vector{Int64}:
 1
 3
 5
 7
 9
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2847-L2871)
```julia
filter(f)
```
Create a function that filters its arguments with function `f` using [`filter`](#Base.filter), i.e. a function equivalent to `x -> filter(f, x)`.
The returned function is of type `Base.Fix1{typeof(filter)}`, which can be used to implement specialized methods.
**Examples**
```julia-repl
julia> (1, 2, Inf, 4, NaN, 6) |> filter(isfinite)
(1, 2, 4, 6)

julia> map(filter(iseven), [1:3, 2:4, 3:5])
3-element Vector{Vector{Int64}}:
 [2]
 [2, 4]
 [4]
```
This method requires at least Julia 1.9.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2934-L2956)
```julia
filter(f, d::AbstractDict)
```
Return a copy of `d`, removing elements for which `f` is `false`. The function `f` is passed `key=>value` pairs.
**Examples**
```julia-repl
julia> d = Dict(1=>"a", 2=>"b")
Dict{Int64, String} with 2 entries:
  2 => "b"
  1 => "a"

julia> filter(p->isodd(p.first), d)
Dict{Int64, String} with 1 entry:
  1 => "a"
```


## [Iterable Collections](#Iterable-Collections)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L459-L476)
```julia
filter(f, itr::SkipMissing{<:AbstractArray})
```
Return a vector similar to the array wrapped by the given `SkipMissing` iterator but with all missing elements and those for which `f` returns `false` removed.
This method requires Julia 1.2 or later.
**Examples**
```julia-repl
julia> x = [1 2; missing 4]
2×2 Matrix{Union{Missing, Int64}}:
 1         2
  missing  4

julia> filter(isodd, skipmissing(x))
1-element Vector{Int64}:
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/missing.jl#L364-L384)
```julia
filter!(f, a)
```
Update collection `a`, removing elements for which `f` is `false`. The function `f` is passed one argument.
**Examples**
```julia-repl
julia> filter!(isodd, Vector(1:10))
5-element Vector{Int64}:
 1
 3
 5
 7
 9
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2901-L2917)
```julia
filter!(f, d::AbstractDict)
```
Update `d`, removing elements for which `f` is `false`. The function `f` is passed `key=>value` pairs.
**Examples**
```julia-repl
julia> d = Dict(1=>"a", 2=>"b", 3=>"c")
Dict{Int64, String} with 3 entries:
  2 => "b"
  3 => "c"
  1 => "a"

julia> filter!(p->isodd(p.first), d)
Dict{Int64, String} with 2 entries:
  3 => "c"
  1 => "a"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L417-L436)


## [Iterable Collections](#Iterable-Collections)
```julia
replace(A, old_new::Pair...; [count::Integer])
```
Return a copy of collection `A` where, for each pair `old=>new` in `old_new`, all occurrences of `old` are replaced by `new`. Equality is determined using [`isequal`](../base/#Base.isequal). If `count` is specified, then replace at most `count` occurrences in total.
The element type of the result is chosen using promotion (see [`promote_type`](../base/#Base.promote_type)) based on the element type of `A` and on the types of the `new` values in pairs. If `count` is omitted and the element type of `A` is a `Union`, the element type of the result will not include singleton types which are replaced with values of a different type: for example, `Union{T,Missing}` will become `T` if `missing` is replaced.
See also [`replace!`](#Base.replace!), [`splice!`](#Base.splice!), [`delete!`](#Base.delete!), [`insert!`](#Base.insert!).
Version 1.7 is required to replace elements of a `Tuple`.
**Examples**
```julia-repl
julia> replace([1, 2, 1, 3], 1=>0, 2=>4, count=2)
4-element Vector{Int64}:
 0
 4
 1
 3

julia> replace([1, missing], missing=>0)
2-element Vector{Int64}:
 1
 0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L780-L814)
```julia
replace(new::Union{Function, Type}, A; [count::Integer])
```
Return a copy of `A` where each value `x` in `A` is replaced by `new(x)`. If `count` is specified, then replace at most `count` values in total (replacements being defined as `new(x) !== x`).


## [Iterable Collections](#Iterable-Collections)
Version 1.7 is required to replace elements of a `Tuple`.
**Examples**
```julia-repl
julia> replace(x -> isodd(x) ? 2x : x, [1, 2, 3, 4])
4-element Vector{Int64}:
 2
 2
 6
 4

julia> replace(Dict(1=>2, 3=>4)) do kv
           first(kv) < 3 ? first(kv)=>3 : kv
       end
Dict{Int64, Int64} with 2 entries:
  3 => 4
  1 => 3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L841-L867)
```julia
replace!(A, old_new::Pair...; [count::Integer])
```
For each pair `old=>new` in `old_new`, replace all occurrences of `old` in collection `A` by `new`. Equality is determined using [`isequal`](../base/#Base.isequal). If `count` is specified, then replace at most `count` occurrences in total. See also [`replace`](#Base.replace-Tuple%7BAny,%20Vararg%7BPair%7D%7D).
**Examples**
```julia-repl
julia> replace!([1, 2, 1, 3], 1=>0, 2=>4, count=2)
4-element Vector{Int64}:
 0
 4
 1
 3

julia> replace!(Set([1, 2, 3]), 1=>0)
Set{Int64} with 3 elements:
  0
  2
  3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L710-L734)
```julia
replace!(new::Union{Function, Type}, A; [count::Integer])
```
Replace each element `x` in collection `A` by `new(x)`. If `count` is specified, then replace at most `count` values in total (replacements being defined as `new(x) !== x`).
**Examples**


## [Iterable Collections](#Iterable-Collections)
```julia-repl
julia> replace!(x -> isodd(x) ? 2x : x, [1, 2, 3, 4])
4-element Vector{Int64}:
 2
 2
 6
 4

julia> replace!(Dict(1=>2, 3=>4)) do kv
           first(kv) < 3 ? first(kv)=>3 : kv
       end
Dict{Int64, Int64} with 2 entries:
  3 => 4
  1 => 3

julia> replace!(x->2x, Set([3, 6]))
Set{Int64} with 2 elements:
  6
  12
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L748-L776)
```julia
Base.rest(collection[, itr_state])
```
Generic function for taking the tail of `collection`, starting from a specific iteration state `itr_state`. Return a `Tuple`, if `collection` itself is a `Tuple`, a subtype of `AbstractVector`, if `collection` is an `AbstractArray`, a subtype of `AbstractString` if `collection` is an `AbstractString`, and an arbitrary iterator, falling back to `Iterators.rest(collection[, itr_state])`, otherwise.
Can be overloaded for user-defined collection types to customize the behavior of [slurping in assignments](../../manual/functions/#destructuring-assignment) in final position, like `a, b... = collection`.
`Base.rest` requires at least Julia 1.6.
See also: [`first`](#Base.first), [`Iterators.rest`](../iterators/#Base.Iterators.rest), [`Base.split_rest`](#Base.split_rest).
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> first, state = iterate(a)
(1, 2)

julia> first, Base.rest(a, state)
(1, [3, 2, 4])
```


## [Iterable Collections](#Iterable-Collections)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L172-L202)
```julia
Base.split_rest(collection, n::Int[, itr_state]) -> (rest_but_n, last_n)
```
Generic function for splitting the tail of `collection`, starting from a specific iteration state `itr_state`. Returns a tuple of two new collections. The first one contains all elements of the tail but the `n` last ones, which make up the second collection.
The type of the first collection generally follows that of [`Base.rest`](#Base.rest), except that the fallback case is not lazy, but is collected eagerly into a vector.
Can be overloaded for user-defined collection types to customize the behavior of [slurping in assignments](../../manual/functions/#destructuring-assignment) in non-final position, like `a, b..., c = collection`.
`Base.split_rest` requires at least Julia 1.9.
See also: [`Base.rest`](#Base.rest).
**Examples**
```julia-repl
julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> first, state = iterate(a)
(1, 2)

julia> first, Base.split_rest(a, 1, state)
(1, ([3, 2], [4]))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/tuple.jl#L210-L241)


## [Indexable Collections](#Indexable-Collections)
```julia
getindex(collection, key...)
```
Retrieve the value(s) stored at the given key or index within a collection. The syntax `a[i,j,...]` is converted by the compiler to `getindex(a, i, j, ...)`.
See also [`get`](#Base.get), [`keys`](#Base.keys), [`eachindex`](../arrays/#Base.eachindex).
**Examples**
```julia-repl
julia> A = Dict("a" => 1, "b" => 2)
Dict{String, Int64} with 2 entries:
  "b" => 2
  "a" => 1

julia> getindex(A, "a")
1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L906-L924)
```julia
setindex!(collection, value, key...)
```
Store the given value at the given key or index within a collection. The syntax `a[i,j,...] = x` is converted by the compiler to `(setindex!(a, x, i, j, ...); x)`.
**Examples**
```julia-repl
julia> a = Dict("a"=>1)
Dict{String, Int64} with 1 entry:
  "a" => 1

julia> setindex!(a, 2, "b")
Dict{String, Int64} with 2 entries:
  "b" => 2
  "a" => 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L964-L981)
```julia
firstindex(collection) -> Integer
firstindex(collection, d) -> Integer
```
Return the first index of `collection`. If `d` is given, return the first index of `collection` along dimension `d`.
The syntaxes `A[begin]` and `A[1, begin]` lower to `A[firstindex(A)]` and `A[1, firstindex(A, 2)]`, respectively.
See also: [`first`](#Base.first), [`axes`](../arrays/#Base.axes-Tuple%7BAny%7D), [`lastindex`](#Base.lastindex), [`nextind`](../arrays/#Base.nextind).


## [Indexable Collections](#Indexable-Collections)
**Examples**
```julia-repl
julia> firstindex([1,2,4])
1

julia> firstindex(rand(3,4,5), 2)
1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L429-L448)
```julia
lastindex(collection) -> Integer
lastindex(collection, d) -> Integer
```
Return the last index of `collection`. If `d` is given, return the last index of `collection` along dimension `d`.
The syntaxes `A[end]` and `A[end, end]` lower to `A[lastindex(A)]` and `A[lastindex(A, 1), lastindex(A, 2)]`, respectively.
See also: [`axes`](../arrays/#Base.axes-Tuple%7BAny%7D), [`firstindex`](#Base.firstindex), [`eachindex`](../arrays/#Base.eachindex), [`prevind`](../arrays/#Base.prevind).
**Examples**
```julia-repl
julia> lastindex([1,2,4])
3

julia> lastindex(rand(3,4,5), 2)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L406-L425)
Fully implemented by:
-   [`Array`](../arrays/#Core.Array)
-   [`BitArray`](../arrays/#Base.BitArray)
-   [`AbstractArray`](../arrays/#Core.AbstractArray)
-   `SubArray`
Partially implemented by:
-   [`AbstractRange`](#Base.AbstractRange)
-   [`UnitRange`](#Base.UnitRange)
-   [`Tuple`](../base/#Core.Tuple)
-   [`AbstractString`](../strings/#Core.AbstractString)
-   [`Dict`](#Base.Dict)
-   [`IdDict`](#Base.IdDict)
-   [`WeakKeyDict`](#Base.WeakKeyDict)
-   [`NamedTuple`](../base/#Core.NamedTuple)


## [Dictionaries](#Dictionaries)
[`Dict`](#Base.Dict) is the standard dictionary. Its implementation uses [`hash`](../base/#Base.hash) as the hashing function for the key, and [`isequal`](../base/#Base.isequal) to determine equality. Define these two functions for custom types to override how they are stored in a hash table.
[`IdDict`](#Base.IdDict) is a special hash table where the keys are always object identities.
[`WeakKeyDict`](#Base.WeakKeyDict) is a hash table implementation where the keys are weak references to objects, and thus may be garbage collected even when referenced in a hash table. Like `Dict` it uses `hash` for hashing and `isequal` for equality, unlike `Dict` it does not convert keys on insertion.
[`Dict`](#Base.Dict)s can be created by passing pair objects constructed with `=>` to a [`Dict`](#Base.Dict) constructor: `Dict("A"=>1, "B"=>2)`. This call will attempt to infer type information from the keys and values (i.e. this example creates a `Dict{String, Int64}`). To explicitly specify types use the syntax `Dict{KeyType,ValueType}(...)`. For example, `Dict{String,Int32}("A"=>1, "B"=>2)`.
Dictionaries may also be created with generators. For example, `Dict(i => f(i) for i = 1:10)`.


## [Dictionaries](#Dictionaries)
Given a dictionary `D`, the syntax `D[x]` returns the value of key `x` (if it exists) or throws an error, and `D[x] = y` stores the key-value pair `x => y` in `D` (replacing any existing value for the key `x`). Multiple arguments to `D[...]` are converted to tuples; for example, the syntax `D[x,y]` is equivalent to `D[(x,y)]`, i.e. it refers to the value keyed by the tuple `(x,y)`.
```julia
AbstractDict{K, V}
```
Supertype for dictionary-like types with keys of type `K` and values of type `V`. [`Dict`](#Base.Dict), [`IdDict`](#Base.IdDict) and other types are subtypes of this. An `AbstractDict{K, V}` should be an iterator of `Pair{K, V}`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L28-L34)
```julia
Dict([itr])
```
`Dict{K,V}()` constructs a hash table with keys of type `K` and values of type `V`. Keys are compared with [`isequal`](../base/#Base.isequal) and hashed with [`hash`](../base/#Base.hash).
Given a single iterable argument, constructs a [`Dict`](#Base.Dict) whose key-value pairs are taken from 2-tuples `(key,value)` generated by the argument.
**Examples**
```julia-repl
julia> Dict([("A", 1), ("B", 2)])
Dict{String, Int64} with 2 entries:
  "B" => 2
  "A" => 1
```
Alternatively, a sequence of pair arguments may be passed.
```julia-repl
julia> Dict("A"=>1, "B"=>2)
Dict{String, Int64} with 2 entries:
  "B" => 2
  "A" => 1
```


## [Dictionaries](#Dictionaries)
Keys are allowed to be mutable, but if you do mutate stored keys, the hash table may become internally inconsistent, in which case the `Dict` will not work properly. [`IdDict`](#Base.IdDict) can be an alternative if you need to mutate keys.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L31-L64)
```julia
IdDict([itr])
```
`IdDict{K,V}()` constructs a hash table using [`objectid`](../base/#Base.objectid) as hash and `===` as equality with keys of type `K` and values of type `V`. See [`Dict`](#Base.Dict) for further help and [`IdSet`](#Base.IdSet) for the set version of this.
In the example below, the `Dict` keys are all `isequal` and therefore get hashed the same, so they get overwritten. The `IdDict` hashes by object-id, and thus preserves the 3 different keys.
**Examples**
```julia-repl
julia> Dict(true => "yes", 1 => "no", 1.0 => "maybe")
Dict{Real, String} with 1 entry:
  1.0 => "maybe"

julia> IdDict(true => "yes", 1 => "no", 1.0 => "maybe")
IdDict{Any, String} with 3 entries:
  true => "yes"
  1.0  => "maybe"
  1    => "no"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/iddict.jl#L3-L26)
```julia
WeakKeyDict([itr])
```
`WeakKeyDict()` constructs a hash table where the keys are weak references to objects which may be garbage collected even when referenced in a hash table.


## [Dictionaries](#Dictionaries)
See [`Dict`](#Base.Dict) for further help. Note, unlike [`Dict`](#Base.Dict), `WeakKeyDict` does not convert keys on insertion, as this would imply the key object was unreferenced anywhere before insertion.
See also [`WeakRef`](../base/#Core.WeakRef).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/weakkeydict.jl#L5-L17)
```julia
ImmutableDict
```
`ImmutableDict` is a dictionary implemented as an immutable linked list, which is optimal for small dictionaries that are constructed over many individual insertions. Note that it is not possible to remove a value, although it can be partially overridden and hidden by inserting a new value with the same key.
```julia
ImmutableDict(KV::Pair)
```
Create a new entry in the `ImmutableDict` for a `key => value` pair
-   use `(key => value) in dict` to see if this particular combination is in the properties set
-   use `get(dict, key, default)` to retrieve the most recent value for a particular key
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L778-L793)
```julia
PersistentDict
```
`PersistentDict` is a dictionary implemented as an hash array mapped trie, which is optimal for situations where you need persistence, each operation returns a new dictionary separate from the previous one, but the underlying implementation is space-efficient and may share storage across multiple separate dictionaries.
It behaves like an IdDict.
```julia
PersistentDict(KV::Pair)
```
**Examples**


## [Dictionaries](#Dictionaries)
```julia-repl
julia> dict = Base.PersistentDict(:a=>1)
Base.PersistentDict{Symbol, Int64} with 1 entry:
  :a => 1

julia> dict2 = Base.delete(dict, :a)
Base.PersistentDict{Symbol, Int64}()

julia> dict3 = Base.PersistentDict(dict, :a=>2)
Base.PersistentDict{Symbol, Int64} with 1 entry:
  :a => 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L907-L937)
```julia
haskey(collection, key) -> Bool
```
Determine whether a collection has a mapping for a given `key`.
**Examples**
```julia-repl
julia> D = Dict('a'=>2, 'b'=>3)
Dict{Char, Int64} with 2 entries:
  'a' => 2
  'b' => 3

julia> haskey(D, 'a')
true

julia> haskey(D, 'c')
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L529-L547)
```julia
get(collection, key, default)
```
Return the value stored for the given key, or the given default value if no mapping for the key is present.
For tuples and numbers, this function requires at least Julia 1.7.
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2);

julia> get(d, "a", 3)
1

julia> get(d, "c", 3)
3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L480-L499)
```julia
get(f::Union{Function, Type}, collection, key)
```
Return the value stored for the given key, or if no mapping for the key is present, return `f()`. Use [`get!`](#Base.get!) to also store the default value in the dictionary.
This is intended to be called using `do` block syntax


## [Dictionaries](#Dictionaries)
```julia
get(dict, key) do
    # default value calculated here
    time()
end
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L507-L521)
```julia
get!(collection, key, default)
```
Return the value stored for the given key, or if no mapping for the key is present, store `key => default`, and return `default`.
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2, "c"=>3);

julia> get!(d, "a", 5)
1

julia> get!(d, "d", 4)
4

julia> d
Dict{String, Int64} with 4 entries:
  "c" => 3
  "b" => 2
  "a" => 1
  "d" => 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L385-L408)
```julia
get!(f::Union{Function, Type}, collection, key)
```
Return the value stored for the given key, or if no mapping for the key is present, store `key => f()`, and return `f()`.
This is intended to be called using `do` block syntax.
**Examples**
```julia-repl
julia> squares = Dict{Int, Int}();

julia> function get_square!(d, i)
           get!(d, i) do
               i^2
           end
       end
get_square! (generic function with 1 method)

julia> get_square!(squares, 2)
4

julia> squares
Dict{Int64, Int64} with 1 entry:
  2 => 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L411-L437)
```julia
getkey(collection, key, default)
```
Return the key matching argument `key` if one exists in `collection`, otherwise return `default`.
**Examples**


## [Dictionaries](#Dictionaries)
```julia-repl
julia> D = Dict('a'=>2, 'b'=>3)
Dict{Char, Int64} with 2 entries:
  'a' => 2
  'b' => 3

julia> getkey(D, 'a', 1)
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)

julia> getkey(D, 'd', 'a')
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L551-L569)
```julia
delete!(collection, key)
```
Delete the mapping for the given key in a collection, if any, and return the collection.
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2)
Dict{String, Int64} with 2 entries:
  "b" => 2
  "a" => 1

julia> delete!(d, "b")
Dict{String, Int64} with 1 entry:
  "a" => 1

julia> delete!(d, "b") # d is left unchanged
Dict{String, Int64} with 1 entry:
  "a" => 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L651-L671)
```julia
pop!(collection, key[, default])
```
Delete and return the mapping for `key` if it exists in `collection`, otherwise return `default`, or throw an error if `default` is not specified.
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2, "c"=>3);

julia> pop!(d, "a")
1

julia> pop!(d, "d")
ERROR: KeyError: key "d" not found
Stacktrace:
[...]

julia> pop!(d, "e", 4)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L586-L607)
```julia
keys(iterator)
```
For an iterator or collection that has keys and values (e.g. arrays and dictionaries), return an iterator over the keys.


## [Dictionaries](#Dictionaries)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L75-L80)
```julia
values(iterator)
```
For an iterator or collection that has keys and values, return an iterator over the values. This function simply returns its argument by default, since the elements of a general iterator are normally considered its "values".
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2);

julia> values(d)
ValueIterator for a Dict{String, Int64} with 2 entries. Values:
  2
  1

julia> values([2])
1-element Vector{Int64}:
 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L1124-L1145)
```julia
values(a::AbstractDict)
```
Return an iterator over all values in a collection. `collect(values(a))` returns an array of values. When the values are stored internally in a hash table, as is the case for `Dict`, the order in which they are returned may vary. But `keys(a)`, `values(a)` and `pairs(a)` all iterate `a` and return the elements in the same order.
**Examples**
```julia-repl
julia> D = Dict('a'=>2, 'b'=>3)
Dict{Char, Int64} with 2 entries:
  'a' => 2
  'b' => 3

julia> collect(values(D))
2-element Vector{Int64}:
 2
 3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L109-L132)
```julia
pairs(IndexLinear(), A)
pairs(IndexCartesian(), A)
pairs(IndexStyle(A), A)
```


## [Dictionaries](#Dictionaries)
An iterator that accesses each element of the array `A`, returning `i => x`, where `i` is the index for the element and `x = A[i]`. Identical to `pairs(A)`, except that the style of index can be selected. Also similar to `enumerate(A)`, except `i` will be a valid index for `A`, while `enumerate` always counts from 1 regardless of the indices of `A`.
Specifying [`IndexLinear()`](../arrays/#Base.IndexLinear) ensures that `i` will be an integer; specifying [`IndexCartesian()`](../arrays/#Base.IndexCartesian) ensures that `i` will be a [`Base.CartesianIndex`](../arrays/#Base.IteratorsMD.CartesianIndex); specifying `IndexStyle(A)` chooses whichever has been defined as the native indexing style for array `A`.
Mutation of the bounds of the underlying array will invalidate this iterator.
**Examples**
```julia-repl
julia> A = ["a" "d"; "b" "e"; "c" "f"];

julia> for (index, value) in pairs(IndexStyle(A), A)
           println("$index $value")
       end
1 a
2 b
3 c
4 d
5 e
6 f

julia> S = view(A, 1:2, :);

julia> for (index, value) in pairs(IndexStyle(S), S)
           println("$index $value")
       end
CartesianIndex(1, 1) a
CartesianIndex(2, 1) b
CartesianIndex(1, 2) d
CartesianIndex(2, 2) e
```
See also [`IndexStyle`](../arrays/#Base.IndexStyle), [`axes`](../arrays/#Base.axes-Tuple%7BAny%7D).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/iterators.jl#L228-L273)
```julia
pairs(collection)
```


## [Dictionaries](#Dictionaries)
Return an iterator over `key => value` pairs for any collection that maps a set of keys to a set of values. This includes arrays, where the keys are the array indices. When the entries are stored internally in a hash table, as is the case for `Dict`, the order in which they are returned may vary. But `keys(a)`, `values(a)` and `pairs(a)` all iterate `a` and return the elements in the same order.
**Examples**
```julia-repl
julia> a = Dict(zip(["a", "b", "c"], [1, 2, 3]))
Dict{String, Int64} with 3 entries:
  "c" => 3
  "b" => 2
  "a" => 1

julia> pairs(a)
Dict{String, Int64} with 3 entries:
  "c" => 3
  "b" => 2
  "a" => 1

julia> foreach(println, pairs(["a", "b", "c"]))
1 => "a"
2 => "b"
3 => "c"

julia> (;a=1, b=2, c=3) |> pairs |> collect
3-element Vector{Pair{Symbol, Int64}}:
 :a => 1
 :b => 2
 :c => 3

julia> (;a=1, b=2, c=3) |> collect
3-element Vector{Int64}:
 1
 2
 3
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L135-L177)
```julia
merge(initial::Face, others::Face...)
```
Merge the properties of the `initial` face and `others`, with later faces taking priority.
```julia
merge(d::AbstractDict, others::AbstractDict...)
```


## [Dictionaries](#Dictionaries)
Construct a merged collection from the given collections. If necessary, the types of the resulting collection will be promoted to accommodate the types of the merged collections. If the same key is present in another collection, the value for that key will be the value it has in the last collection listed. See also [`mergewith`](#Base.mergewith) for custom handling of values with the same key.
**Examples**
```julia-repl
julia> a = Dict("foo" => 0.0, "bar" => 42.0)
Dict{String, Float64} with 2 entries:
  "bar" => 42.0
  "foo" => 0.0

julia> b = Dict("baz" => 17, "bar" => 4711)
Dict{String, Int64} with 2 entries:
  "bar" => 4711
  "baz" => 17

julia> merge(a, b)
Dict{String, Float64} with 3 entries:
  "bar" => 4711.0
  "baz" => 17.0
  "foo" => 0.0

julia> merge(b, a)
Dict{String, Float64} with 3 entries:
  "bar" => 42.0
  "baz" => 17.0
  "foo" => 0.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L325-L358)
```julia
merge(a::NamedTuple, bs::NamedTuple...)
```


## [Dictionaries](#Dictionaries)
Construct a new named tuple by merging two or more existing ones, in a left-associative manner. Merging proceeds left-to-right, between pairs of named tuples, and so the order of fields present in both the leftmost and rightmost named tuples take the same position as they are found in the leftmost named tuple. However, values are taken from matching fields in the rightmost named tuple that contains that field. Fields present in only the rightmost named tuple of a pair are appended at the end. A fallback is implemented for when only a single named tuple is supplied, with signature `merge(a::NamedTuple)`.
Merging 3 or more `NamedTuple` requires at least Julia 1.1.
**Examples**
```julia-repl
julia> merge((a=1, b=2, c=3), (b=4, d=5))
(a = 1, b = 4, c = 3, d = 5)
```
```julia-repl
julia> merge((a=1, b=2), (b=3, c=(d=1,)), (c=(d=2,),))
(a = 1, b = 3, c = (d = 2,))
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/namedtuple.jl#L309-L333)
```julia
merge(a::NamedTuple, iterable)
```
Interpret an iterable of key-value pairs as a named tuple, and perform a merge.
```julia-repl
julia> merge((a=1, b=2, c=3), [:b=>4, :d=>5])
(a = 1, b = 4, c = 3, d = 5)
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/namedtuple.jl#L357-L366)
```julia
mergewith(combine, d::AbstractDict, others::AbstractDict...)
mergewith(combine)
merge(combine, d::AbstractDict, others::AbstractDict...)
```


## [Dictionaries](#Dictionaries)
Construct a merged collection from the given collections. If necessary, the types of the resulting collection will be promoted to accommodate the types of the merged collections. Values with the same key will be combined using the combiner function. The curried form `mergewith(combine)` returns the function `(args...) -> mergewith(combine, args...)`.
Method `merge(combine::Union{Function,Type}, args...)` as an alias of `mergewith(combine, args...)` is still available for backward compatibility.
`mergewith` requires Julia 1.5 or later.
**Examples**
```julia-repl
julia> a = Dict("foo" => 0.0, "bar" => 42.0)
Dict{String, Float64} with 2 entries:
  "bar" => 42.0
  "foo" => 0.0

julia> b = Dict("baz" => 17, "bar" => 4711)
Dict{String, Int64} with 2 entries:
  "bar" => 4711
  "baz" => 17

julia> mergewith(+, a, b)
Dict{String, Float64} with 3 entries:
  "bar" => 4753.0
  "baz" => 17.0
  "foo" => 0.0

julia> ans == mergewith(+)(a, b)
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L362-L400)
```julia
merge!(d::AbstractDict, others::AbstractDict...)
```
Update collection with pairs from the other collections. See also [`merge`](#Base.merge).
**Examples**
```julia-repl
julia> d1 = Dict(1 => 2, 3 => 4);

julia> d2 = Dict(1 => 4, 4 => 5);

julia> merge!(d1, d2);

julia> d1
Dict{Int64, Int64} with 3 entries:
  4 => 5
  3 => 4
  1 => 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L203-L223)


## [Dictionaries](#Dictionaries)
```julia
mergewith!(combine, d::AbstractDict, others::AbstractDict...) -> d
mergewith!(combine)
merge!(combine, d::AbstractDict, others::AbstractDict...) -> d
```
Update collection with pairs from the other collections. Values with the same key will be combined using the combiner function. The curried form `mergewith!(combine)` returns the function `(args...) -> mergewith!(combine, args...)`.
Method `merge!(combine::Union{Function,Type}, args...)` as an alias of `mergewith!(combine, args...)` is still available for backward compatibility.
`mergewith!` requires Julia 1.5 or later.
**Examples**
```julia-repl
julia> d1 = Dict(1 => 2, 3 => 4);

julia> d2 = Dict(1 => 4, 4 => 5);

julia> mergewith!(+, d1, d2);

julia> d1
Dict{Int64, Int64} with 3 entries:
  4 => 5
  3 => 4
  1 => 6

julia> mergewith!(-, d1, d1);

julia> d1
Dict{Int64, Int64} with 3 entries:
  4 => 0
  3 => 0
  1 => 0

julia> foldl(mergewith!(+), [d1, d2]; init=Dict{Int64, Int64}())
Dict{Int64, Int64} with 3 entries:
  4 => 5
  3 => 0
  1 => 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L236-L281)
```julia
sizehint!(s, n; first::Bool=false, shrink::Bool=true) -> s
```
Suggest that collection `s` reserve capacity for at least `n` elements. That is, if you expect that you're going to have to push a lot of values onto `s`, you can avoid the cost of incremental reallocation by doing it once up front; this can improve performance.


## [Dictionaries](#Dictionaries)
If `first` is `true`, then any additional space is reserved before the start of the collection. This way, subsequent calls to `pushfirst!` (instead of `push!`) may become faster. Supplying this keyword may result in an error if the collection is not ordered or if `pushfirst!` is not supported for this collection.
If `shrink=true` (the default), the collection's capacity may be reduced if its current capacity is greater than `n`.
See also [`resize!`](#Base.resize!).
**Notes on the performance model**
For types that support `sizehint!`,
1.  `push!` and `append!` methods generally may (but are not required to) preallocate extra storage. For types implemented in `Base`, they typically do, using a heuristic optimized for a general use case.
2.  `sizehint!` may control this preallocation. Again, it typically does this for types in `Base`.
3.  `empty!` is nearly costless (and O(1)) for types that support this kind of preallocation.
The `shrink` and `first` arguments were added in Julia 1.11.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1461-L1494)
```julia
keytype(T::Type{<:AbstractArray})
keytype(A::AbstractArray)
```
Return the key type of an array. This is equal to the [`eltype`](#Base.eltype) of the result of `keys(...)`, and is provided mainly for compatibility with the dictionary interface.
**Examples**
```julia-repl
julia> keytype([1, 2, 3]) == Int
true

julia> keytype([1 2; 3 4])
CartesianIndex{2}
```
For arrays, this function requires at least Julia 1.2.


## [Dictionaries](#Dictionaries)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L168-L187)
```julia
keytype(type)
```
Get the key type of a dictionary type. Behaves similarly to [`eltype`](#Base.eltype).
**Examples**
```julia-repl
julia> keytype(Dict(Int32(1) => "foo"))
Int32
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L297-L307)
```julia
valtype(T::Type{<:AbstractArray})
valtype(A::AbstractArray)
```
Return the value type of an array. This is identical to [`eltype`](#Base.eltype) and is provided mainly for compatibility with the dictionary interface.
**Examples**
```julia-repl
julia> valtype(["one", "two", "three"])
String
```
For arrays, this function requires at least Julia 1.2.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractarray.jl#L197-L212)
```julia
valtype(type)
```
Get the value type of a dictionary type. Behaves similarly to [`eltype`](#Base.eltype).
**Examples**
```julia-repl
julia> valtype(Dict(Int32(1) => "foo"))
String
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractdict.jl#L311-L321)
Fully implemented by:
-   [`Dict`](#Base.Dict)
-   [`IdDict`](#Base.IdDict)
-   [`WeakKeyDict`](#Base.WeakKeyDict)
Partially implemented by:
-   [`Set`](#Base.Set)
-   [`BitSet`](#Base.BitSet)
-   [`IdSet`](#Base.IdSet)
-   [`EnvDict`](../base/#Base.EnvDict)
-   [`Array`](../arrays/#Core.Array)


## [Dictionaries](#Dictionaries)
-   [`BitArray`](../arrays/#Base.BitArray)
-   [`ImmutableDict`](#Base.ImmutableDict)
-   [`PersistentDict`](#Base.PersistentDict)
-   [`Iterators.Pairs`](#Base.Pairs)


## [Set-Like Collections](#Set-Like-Collections)
```julia
AbstractSet{T}
```
Supertype for set-like types whose elements are of type `T`. [`Set`](#Base.Set), [`BitSet`](#Base.BitSet) and other types are subtypes of this.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L20-L25)
```julia
Set{T} <: AbstractSet{T}
```
`Set`s are mutable containers that provide fast membership testing.
`Set`s have efficient implementations of set operations such as `in`, `union` and `intersect`. Elements in a `Set` are unique, as determined by the elements' definition of `isequal`. The order of elements in a `Set` is an implementation detail and cannot be relied on.
See also: [`AbstractSet`](#Base.AbstractSet), [`BitSet`](#Base.BitSet), [`Dict`](#Base.Dict), [`push!`](#Base.push!), [`empty!`](#Base.empty!), [`union!`](#Base.union!), [`in`](#Base.in), [`isequal`](../base/#Base.isequal)
**Examples**
```julia-repl
julia> s = Set("aaBca")
Set{Char} with 3 elements:
  'a'
  'c'
  'B'

julia> push!(s, 'b')
Set{Char} with 4 elements:
  'a'
  'b'
  'B'
  'c'

julia> s = Set([NaN, 0.0, 1.0, 2.0]);

julia> -0.0 in s # isequal(0.0, -0.0) is false
false

julia> NaN in s # isequal(NaN, NaN) is true
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L3-L38)
```julia
BitSet([itr])
```


## [Set-Like Collections](#Set-Like-Collections)
Construct a sorted set of `Int`s generated by the given iterable object, or an empty set. Implemented as a bit string, and therefore designed for dense integer sets. If the set will be sparse (for example, holding a few very large integers), use [`Set`](#Base.Set) instead.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/bitset.jl#L25-L32)
```julia
IdSet{T}([itr])
IdSet()
```
IdSet{T}() constructs a set (see [`Set`](#Base.Set)) using `===` as equality with values of type `T`.
In the example below, the values are all `isequal` so they get overwritten in the ordinary `Set`. The `IdSet` compares by `===` and so preserves the 3 different values.
**Examples**
```julia-repl
julia> Set(Any[true, 1, 1.0])
Set{Any} with 1 element:
  1.0

julia> IdSet{Any}(Any[true, 1, 1.0])
IdSet{Any} with 3 elements:
  1.0
  1
  true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/idset.jl#L3-L25)
```julia
union(s, itrs...)
∪(s, itrs...)
```
Construct an object containing all distinct elements from all of the arguments.
The first argument controls what kind of container is returned. If this is an array, it maintains the order in which elements first appear.
Unicode `∪` can be typed by writing `\cup` then pressing tab in the Julia REPL, and in many editors. This is an infix operator, allowing `s ∪ itr`.


## [Set-Like Collections](#Set-Like-Collections)
See also [`unique`](#Base.unique), [`intersect`](#Base.intersect), [`isdisjoint`](#Base.isdisjoint), [`vcat`](../arrays/#Base.vcat), [`Iterators.flatten`](../iterators/#Base.Iterators.flatten).
**Examples**
```julia-repl
julia> union([1, 2], [3])
3-element Vector{Int64}:
 1
 2
 3

julia> union([4 2 3 4 4], 1:3, 3.0)
4-element Vector{Float64}:
 4.0
 2.0
 3.0
 1.0

julia> (0, 0.0) ∪ (-0.0, NaN)
3-element Vector{Real}:
   0
  -0.0
 NaN

julia> union(Set([1, 2]), 2:3)
Set{Int64} with 3 elements:
  2
  3
  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L13-L54)
```julia
union!(s::Union{AbstractSet,AbstractVector}, itrs...)
```
Construct the [`union`](#Base.union) of passed in sets and overwrite `s` with the result. Maintain order with arrays.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> a = Set([3, 4, 5]);

julia> union!(a, 1:2:7);

julia> a
Set{Int64} with 5 elements:
  5
  4
  7
  3
  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L62-L84)
```julia
intersect(s, itrs...)
∩(s, itrs...)
```
Construct the set containing those elements which appear in all of the arguments.
The first argument controls what kind of container is returned. If this is an array, it maintains the order in which elements first appear.


## [Set-Like Collections](#Set-Like-Collections)
Unicode `∩` can be typed by writing `\cap` then pressing tab in the Julia REPL, and in many editors. This is an infix operator, allowing `s ∩ itr`.
See also [`setdiff`](#Base.setdiff), [`isdisjoint`](#Base.isdisjoint), [`issubset`](#Base.issubset), [`issetequal`](#Base.issetequal).
As of Julia 1.8 intersect returns a result with the eltype of the type-promoted eltypes of the two inputs
**Examples**
```julia-repl
julia> intersect([1, 2, 3], [3, 4, 5])
1-element Vector{Int64}:
 3

julia> intersect([1, 4, 4, 5, 6], [6, 4, 6, 7, 8])
2-element Vector{Int64}:
 4
 6

julia> intersect(1:16, 7:99)
7:16

julia> (0, 0.0) ∩ (-0.0, 0)
1-element Vector{Real}:
 0

julia> intersect(Set([1, 2]), BitSet([2, 3]), 1.0:10.0)
Set{Float64} with 1 element:
  2.0
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L112-L152)
```julia
setdiff(s, itrs...)
```
Construct the set of elements in `s` but not in any of the iterables in `itrs`. Maintain order with arrays.
See also [`setdiff!`](#Base.setdiff!), [`union`](#Base.union) and [`intersect`](#Base.intersect).
**Examples**
```julia-repl
julia> setdiff([1,2,3], [3,4,5])
2-element Vector{Int64}:
 1
 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L200-L215)
```julia
setdiff!(s, itrs...)
```
Remove from set `s` (in-place) each element of each iterable from `itrs`. Maintain order with arrays.


## [Set-Like Collections](#Set-Like-Collections)
Behavior can be unexpected when any mutated argument shares memory with any other argument.
**Examples**
```julia-repl
julia> a = Set([1, 3, 4, 5]);

julia> setdiff!(a, 1:2:6);

julia> a
Set{Int64} with 1 element:
  4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L219-L237)
```julia
symdiff(s, itrs...)
```
Construct the symmetric difference of elements in the passed in sets. When `s` is not an `AbstractSet`, the order is maintained.
See also [`symdiff!`](#Base.symdiff!), [`setdiff`](#Base.setdiff), [`union`](#Base.union) and [`intersect`](#Base.intersect).
**Examples**
```julia-repl
julia> symdiff([1,2,3], [3,4,5], [4,5,6])
3-element Vector{Int64}:
 1
 2
 6

julia> symdiff([1,2,1], [2, 1, 2])
Int64[]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L252-L271)
```julia
symdiff!(s::Union{AbstractSet,AbstractVector}, itrs...)
```
Construct the symmetric difference of the passed in sets, and overwrite `s` with the result. When `s` is an array, the order is maintained. Note that in this case the multiplicity of elements matters.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L275-L283)
```julia
intersect!(s::Union{AbstractSet,AbstractVector}, itrs...)
```
Intersect all passed in sets and overwrite `s` with the result. Maintain order with arrays.


## [Set-Like Collections](#Set-Like-Collections)
Behavior can be unexpected when any mutated argument shares memory with any other argument.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L182-L189)
```julia
issubset(a, b) -> Bool
⊆(a, b) -> Bool
⊇(b, a) -> Bool
```
Determine whether every element of `a` is also in `b`, using [`in`](#Base.in).
See also [`⊊`](#Base.:⊊), [`⊈`](#Base.:⊈), [`∩`](#Base.intersect), [`∪`](#Base.union), [`contains`](../strings/#Base.contains).
**Examples**
```julia-repl
julia> issubset([1, 2], [1, 2, 3])
true

julia> [1, 2, 3] ⊆ [1, 2]
false

julia> [1, 2, 3] ⊇ [1, 2]
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L304-L324)
```julia
in!(x, s::AbstractSet) -> Bool
```
If `x` is in `s`, return `true`. If not, push `x` into `s` and return `false`. This is equivalent to `in(x, s) ? true : (push!(s, x); false)`, but may have a more efficient implementation.
See also: [`in`](#Base.in), [`push!`](#Base.push!), [`Set`](#Base.Set)
This function requires at least 1.11.
**Examples**
```julia-repl
julia> s = Set{Any}([1, 2, 3]); in!(4, s)
false

julia> length(s)
4

julia> in!(0x04, s)
true

julia> s
Set{Any} with 4 elements:
  4
  2
  3
  1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/set.jl#L94-L124)
```julia
⊈(a, b) -> Bool
⊉(b, a) -> Bool
```
Negation of `⊆` and `⊇`, i.e. checks that `a` is not a subset of `b`.


## [Set-Like Collections](#Set-Like-Collections)
See also [`issubset`](#Base.issubset) (`⊆`), [`⊊`](#Base.:⊊).
**Examples**
```julia-repl
julia> (1, 2) ⊈ (2, 3)
true

julia> (1, 2) ⊈ (1, 2, 3)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L448-L464)
```julia
⊊(a, b) -> Bool
⊋(b, a) -> Bool
```
Determines if `a` is a subset of, but not equal to, `b`.
See also [`issubset`](#Base.issubset) (`⊆`), [`⊈`](#Base.:⊈).
**Examples**
```julia-repl
julia> (1, 2) ⊊ (1, 2, 3)
true

julia> (1, 2) ⊊ (1, 2)
false
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L396-L412)
```julia
issetequal(a, b) -> Bool
```
Determine whether `a` and `b` have the same elements. Equivalent to `a ⊆ b && b ⊆ a` but more efficient when possible.
See also: [`isdisjoint`](#Base.isdisjoint), [`union`](#Base.union).
**Examples**
```julia-repl
julia> issetequal([1, 2], [1, 2, 3])
false

julia> issetequal([1, 2], [2, 1])
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L498-L514)
```julia
issetequal(x)
```
Create a function that compares its argument to `x` using [`issetequal`](#Base.issetequal), i.e. a function equivalent to `y -> issetequal(y, x)`. The returned function is of type `Base.Fix2{typeof(issetequal)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.11.


## [Set-Like Collections](#Set-Like-Collections)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L532-L542)
```julia
isdisjoint(a, b) -> Bool
```
Determine whether the collections `a` and `b` are disjoint. Equivalent to `isempty(a ∩ b)` but more efficient when possible.
See also: [`intersect`](#Base.intersect), [`isempty`](#Base.isempty), [`issetequal`](#Base.issetequal).
This function requires at least Julia 1.5.
**Examples**
```julia-repl
julia> isdisjoint([1, 2], [2, 3, 4])
false

julia> isdisjoint([3, 1], [2, 4])
true
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L546-L565)
```julia
isdisjoint(x)
```
Create a function that compares its argument to `x` using [`isdisjoint`](#Base.isdisjoint), i.e. a function equivalent to `y -> isdisjoint(y, x)`. The returned function is of type `Base.Fix2{typeof(isdisjoint)}`, which can be used to implement specialized methods.
This functionality requires at least Julia 1.11.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/abstractset.jl#L591-L601)
Fully implemented by:
-   [`Set`](#Base.Set)
-   [`BitSet`](#Base.BitSet)
-   [`IdSet`](#Base.IdSet)
Partially implemented by:
-   [`Array`](../arrays/#Core.Array)


## [Dequeues](#Dequeues)
```julia
push!(collection, items...) -> collection
```
Insert one or more `items` in `collection`. If `collection` is an ordered container, the items are inserted at the end (in the given order).
**Examples**
```julia-repl
julia> push!([1, 2, 3], 4, 5, 6)
6-element Vector{Int64}:
 1
 2
 3
 4
 5
 6
```
If `collection` is ordered, use [`append!`](#Base.append!) to add all the elements of another collection to it. The result of the preceding example is equivalent to `append!([1, 2, 3], [4, 5, 6])`. For `AbstractSet` objects, [`union!`](#Base.union!) can be used instead.
See [`sizehint!`](#Base.sizehint!) for notes about the performance model.
See also [`pushfirst!`](#Base.pushfirst!).
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1230-L1255)
```julia
pop!(collection) -> item
```
Remove an item in `collection` and return it. If `collection` is an ordered container, the last item is returned; for unordered containers, an arbitrary element is returned.
See also: [`popfirst!`](#Base.popfirst!), [`popat!`](#Base.popat!), [`delete!`](#Base.delete!), [`deleteat!`](#Base.deleteat!), [`splice!`](#Base.splice!), and [`push!`](#Base.push!).
**Examples**
```julia-repl
julia> A=[1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> pop!(A)
3

julia> A
2-element Vector{Int64}:
 1
 2

julia> S = Set([1, 2])
Set{Int64} with 2 elements:
  2
  1

julia> pop!(S)
2

julia> S
Set{Int64} with 1 element:
  1

julia> pop!(Dict(1=>2))
1 => 2
```


## [Dequeues](#Dequeues)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1539-L1579)
```julia
pop!(collection, key[, default])
```
Delete and return the mapping for `key` if it exists in `collection`, otherwise return `default`, or throw an error if `default` is not specified.
**Examples**
```julia-repl
julia> d = Dict("a"=>1, "b"=>2, "c"=>3);

julia> pop!(d, "a")
1

julia> pop!(d, "d")
ERROR: KeyError: key "d" not found
Stacktrace:
[...]

julia> pop!(d, "e", 4)
4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/dict.jl#L586-L607)
```julia
popat!(a::Vector, i::Integer, [default])
```
Remove the item at the given `i` and return it. Subsequent items are shifted to fill the resulting gap. When `i` is not a valid index for `a`, return `default`, or throw an error if `default` is not specified.
See also: [`pop!`](#Base.pop!), [`popfirst!`](#Base.popfirst!), [`deleteat!`](#Base.deleteat!), [`splice!`](#Base.splice!).
This function is available as of Julia 1.5.
**Examples**
```julia-repl
julia> a = [4, 3, 2, 1]; popat!(a, 2)
3

julia> a
3-element Vector{Int64}:
 4
 2
 1

julia> popat!(a, 4, missing)
missing

julia> popat!(a, 4)
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [4]
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1589-L1620)
```julia
pushfirst!(collection, items...) -> collection
```
Insert one or more `items` at the beginning of `collection`.


## [Dequeues](#Dequeues)
This function is called `unshift` in many other programming languages.
**Examples**
```julia-repl
julia> pushfirst!([1, 2, 3, 4], 5, 6)
6-element Vector{Int64}:
 5
 6
 1
 2
 3
 4
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1637-L1655)
```julia
popfirst!(collection) -> item
```
Remove the first `item` from `collection`.
This function is called `shift` in many other programming languages.
See also: [`pop!`](#Base.pop!), [`popat!`](#Base.popat!), [`delete!`](#Base.delete!).
**Examples**
```julia-repl
julia> A = [1, 2, 3, 4, 5, 6]
6-element Vector{Int64}:
 1
 2
 3
 4
 5
 6

julia> popfirst!(A)
1

julia> A
5-element Vector{Int64}:
 2
 3
 4
 5
 6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1680-L1711)
```julia
insert!(a::Vector, index::Integer, item)
```
Insert an `item` into `a` at the given `index`. `index` is the index of `item` in the resulting `a`.
See also: [`push!`](#Base.push!), [`replace`](#Base.replace-Tuple%7BAny,%20Vararg%7BPair%7D%7D), [`popat!`](#Base.popat!), [`splice!`](#Base.splice!).
**Examples**
```julia-repl
julia> insert!(Any[1:6;], 3, "here")
7-element Vector{Any}:
 1
 2
  "here"
 3
 4
 5
 6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1721-L1741)
```julia
deleteat!(a::Vector, i::Integer)
```
Remove the item at the given `i` and return the modified `a`. Subsequent items are shifted to fill the resulting gap.


## [Dequeues](#Dequeues)
See also: [`keepat!`](#Base.keepat!), [`delete!`](#Base.delete!), [`popat!`](#Base.popat!), [`splice!`](#Base.splice!).
**Examples**
```julia-repl
julia> deleteat!([6, 5, 4, 3, 2, 1], 2)
5-element Vector{Int64}:
 6
 4
 3
 2
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1752-L1770)
```julia
deleteat!(a::Vector, inds)
```
Remove the items at the indices given by `inds`, and return the modified `a`. Subsequent items are shifted to fill the resulting gap.
`inds` can be either an iterator or a collection of sorted and unique integer indices, or a boolean vector of the same length as `a` with `true` indicating entries to delete.
**Examples**
```julia-repl
julia> deleteat!([6, 5, 4, 3, 2, 1], 1:2:5)
3-element Vector{Int64}:
 5
 3
 1

julia> deleteat!([6, 5, 4, 3, 2, 1], [true, false, true, false, true, false])
3-element Vector{Int64}:
 5
 3
 1

julia> deleteat!([6, 5, 4, 3, 2, 1], (2, 2))
ERROR: ArgumentError: indices must be unique and sorted
Stacktrace:
[...]
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1789-L1817)
```julia
keepat!(a::Vector, inds)
keepat!(a::BitVector, inds)
```
Remove the items at all the indices which are not given by `inds`, and return the modified `a`. Items which are kept are shifted to fill the resulting gaps.
Behavior can be unexpected when any mutated argument shares memory with any other argument.


## [Dequeues](#Dequeues)
`inds` must be an iterator of sorted and unique integer indices. See also [`deleteat!`](#Base.deleteat!).
This function is available as of Julia 1.7.
**Examples**
```julia-repl
julia> keepat!([6, 5, 4, 3, 2, 1], 1:2:5)
3-element Vector{Int64}:
 6
 4
 2
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2961-L2985)
```julia
keepat!(a::Vector, m::AbstractVector{Bool})
keepat!(a::BitVector, m::AbstractVector{Bool})
```
The in-place version of logical indexing `a = a[m]`. That is, `keepat!(a, m)` on vectors of equal length `a` and `m` will remove all elements from `a` for which `m` at the corresponding index is `false`.
**Examples**
```julia-repl
julia> a = [:a, :b, :c];

julia> keepat!(a, [true, false, true])
2-element Vector{Symbol}:
 :a
 :c

julia> a
2-element Vector{Symbol}:
 :a
 :c
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L2988-L3010)
```julia
splice!(a::Vector, index::Integer, [replacement]) -> item
```
Remove the item at the given index, and return the removed item. Subsequent items are shifted left to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed item.
See also: [`replace`](#Base.replace-Tuple%7BAny,%20Vararg%7BPair%7D%7D), [`delete!`](#Base.delete!), [`deleteat!`](#Base.deleteat!), [`pop!`](#Base.pop!), [`popat!`](#Base.popat!).
**Examples**


## [Dequeues](#Dequeues)
```julia-repl
julia> A = [6, 5, 4, 3, 2, 1]; splice!(A, 5)
2

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

julia> splice!(A, 5, -1)
1

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

julia> splice!(A, 1, [-1, -2, -3])
6

julia> A
7-element Vector{Int64}:
 -1
 -2
 -3
  5
  4
  3
 -1
```
To insert `replacement` before an index `n` without removing any items, use `splice!(collection, n:n-1, replacement)`.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1892-L1942)
```julia
splice!(a::Vector, indices, [replacement]) -> items
```
Remove items at specified indices, and return a collection containing the removed items. Subsequent items are shifted left to fill the resulting gaps. If specified, replacement values from an ordered collection will be spliced in place of the removed items; in this case, `indices` must be a `AbstractUnitRange`.
To insert `replacement` before an index `n` without removing any items, use `splice!(collection, n:n-1, replacement)`.
Behavior can be unexpected when any mutated argument shares memory with any other argument.
Prior to Julia 1.5, `indices` must always be a `UnitRange`.
Prior to Julia 1.8, `indices` must be a `UnitRange` if splicing in replacement values.
**Examples**
```julia-repl
julia> A = [-1, -2, -3, 5, 4, 3, -1]; splice!(A, 4:3, 2)
Int64[]

julia> A
8-element Vector{Int64}:
 -1
 -2
 -3
  2
  5
  4
  3
 -1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1961-L1997)


## [Dequeues](#Dequeues)
```julia
resize!(a::Vector, n::Integer) -> Vector
```
Resize `a` to contain `n` elements. If `n` is smaller than the current collection length, the first `n` elements will be retained. If `n` is larger, the new elements are not guaranteed to be initialized.
**Examples**
```julia-repl
julia> resize!([6, 5, 4, 3, 2, 1], 3)
3-element Vector{Int64}:
 6
 5
 4

julia> a = resize!([6, 5, 4, 3, 2, 1], 8);

julia> length(a)
8

julia> a[1:6]
6-element Vector{Int64}:
 6
 5
 4
 3
 2
 1
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1417-L1446)
```julia
append!(collection, collections...) -> collection.
```
For an ordered container `collection`, add the elements of each `collections` to the end of it.
Specifying multiple collections to be appended requires at least Julia 1.6.
**Examples**
```julia-repl
julia> append!([1], [2, 3])
3-element Vector{Int64}:
 1
 2
 3

julia> append!([1, 2, 3], [4, 5], [6])
6-element Vector{Int64}:
 1
 2
 3
 4
 5
 6
```
Use [`push!`](#Base.push!) to add individual items to `collection` which are not already themselves in another collection. The result of the preceding example is equivalent to `push!([1, 2, 3], 4, 5, 6)`.
See [`sizehint!`](#Base.sizehint!) for notes about the performance model.
See also [`vcat`](../arrays/#Base.vcat) for vectors, [`union!`](#Base.union!) for sets, and [`prepend!`](#Base.prepend!) and [`pushfirst!`](#Base.pushfirst!) for the opposite order.


## [Dequeues](#Dequeues)
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1283-L1318)
```julia
prepend!(a::Vector, collections...) -> collection
```
Insert the elements of each `collections` to the beginning of `a`.
When `collections` specifies multiple collections, order is maintained: elements of `collections[1]` will appear leftmost in `a`, and so on.
Specifying multiple collections to be prepended requires at least Julia 1.6.
**Examples**
```julia-repl
julia> prepend!([3], [1, 2])
3-element Vector{Int64}:
 1
 2
 3

julia> prepend!([6], [1, 2], [3, 4, 5])
6-element Vector{Int64}:
 1
 2
 3
 4
 5
 6
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/array.jl#L1349-L1377)
Fully implemented by:
-   `Vector` (a.k.a. 1-dimensional [`Array`](../arrays/#Core.Array))
-   `BitVector` (a.k.a. 1-dimensional [`BitArray`](../arrays/#Base.BitArray))


## [Utility Collections](#Utility-Collections)
```julia
Pair(x, y)
x => y
```
Construct a `Pair` object with type `Pair{typeof(x), typeof(y)}`. The elements are stored in the fields `first` and `second`. They can also be accessed via iteration (but a `Pair` is treated as a single "scalar" for broadcasting operations).
See also [`Dict`](#Base.Dict).
**Examples**
```julia-repl
julia> p = "foo" => 7
"foo" => 7

julia> typeof(p)
Pair{String, Int64}

julia> p.first
"foo"

julia> for x in p
           println(x)
       end
foo
7

julia> replace.(["xops", "oxps"], "x" => "o")
2-element Vector{String}:
 "oops"
 "oops"
```
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/pair.jl#L5-L37)
```julia
Base.Pairs(values, keys) <: AbstractDict{eltype(keys), eltype(values)}
```
Transforms an indexable container into a Dictionary-view of the same data. Modifying the key-space of the underlying data may invalidate this object.
[source](https://github.com/JuliaLang/julia/blob/9615af0f269df4d371b8010e9507ed5bae86103b/base/essentials.jl#L488-L493)
------------------------------------------------------------------------