diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 5c4188b0f1471..8bba670b96473 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -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 @@ -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 @@ -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))