Skip to content

Commit

Permalink
doc: add note about reduce([hv]cat, x) in [hv]cat (JuliaLang#44049)
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronBieganek authored and LilithHafner committed Feb 22, 2022
1 parent 5479b52 commit fd96a69
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,8 @@ end
"""
vcat(A...)
Concatenate along dimension 1.
Concatenate along dimension 1. To efficiently concatenate a large vector of arrays,
use `reduce(vcat, x)`.
# Examples
```jldoctest
Expand All @@ -1785,13 +1786,29 @@ julia> vcat(c...)
2×3 Matrix{Int64}:
1 2 3
4 5 6
julia> vs = [[1, 2], [3, 4], [5, 6]]
3-element Vector{Vector{Int64}}:
[1, 2]
[3, 4]
[5, 6]
julia> reduce(vcat, vs)
6-element Vector{Int64}:
1
2
3
4
5
6
```
"""
vcat(X...) = cat(X...; dims=Val(1))
"""
hcat(A...)
Concatenate along dimension 2.
Concatenate along dimension 2. To efficiently concatenate a large vector of arrays,
use `reduce(hcat, x)`.
# Examples
```jldoctest
Expand Down Expand Up @@ -1836,6 +1853,17 @@ julia> hcat(x, [1; 2; 3])
1
2
3
julia> vs = [[1, 2], [3, 4], [5, 6]]
3-element Vector{Vector{Int64}}:
[1, 2]
[3, 4]
[5, 6]
julia> reduce(hcat, vs)
2×3 Matrix{Int64}:
1 3 5
2 4 6
```
"""
hcat(X...) = cat(X...; dims=Val(2))
Expand Down

0 comments on commit fd96a69

Please sign in to comment.