julia> reduce(vcat, [1,2])
2-element Vector{Int64}:
1
2
julia> reduce(vcat, [1])
1
1 Like
This thread Inconsistency with `reduce(vcat, v)` when the vector has a single element has some links to past discussions about this issue
1 Like
Try passing an initial value:
julia> reduce(vcat, [1]; init=Int[])
1-element Vector{Int64}:
1
Also vcat
takes k
collections so your current code treats 1
as a collection, which works because Julia numbers are iterable but it’s not that nice imo: I prefer to use real collections:
julia> reduce(vcat, [[1]]; init=Int[])
1-element Vector{Int64}:
1
3 Likes