That doesn’t quite seem to do what you want, Mauro:
julia> arr_of_arr = Vector{Int}[[1],[2,3],[4,5]]
3-element Array{Array{Int64,1},1}:
[1]
[2,3]
[4,5]
julia> vcat_nosplat(y) = eltype(y[1])[el[1] for el in y]
vcat_nosplat (generic function with 1 method)
julia> vcat_nosplat(arr_of_arr)
3-element Array{Int64,1}:
1
2
4
It’s quite trivial to achieve the desired result with only a few lines of
code, though:
julia> function vcat_nosplat2(y)
result = Array(eltype(y[1]), 0)
sizehint!(result, sum(map(length, y))) #skip if iterating is more
expensive than reallcoation
for a in y
for x in a
push!(result, x)
end
end
result
end
vcat_nosplat2 (generic function with 1 method)
julia> vcat_nosplat2(arr_of_arr)
5-element Array{Int64,1}:
1
2
3
4
5
// T
On Sunday, November 22, 2015 at 9:12:55 PM UTC+1, Mauro wrote:
In ODE.jl, I've used
>
> vcat_nosplat(y) = eltype(y[1])[el[1] for el in y] # Does vcat(y...)
> without the splatting
>
> I think the eltype might not be needed. There may be better ways though.
>
> On Sun, 2015-11-22 at 14:04, Cedric St-Jean <[email protected]
> <javascript:>> wrote:
> > I have a big vector of vectors. Is there any way to vcat/hcat them
> without
> > splatting?
> >
> > arr_of_arr = Vector[[1],[2,3],[4,5]]
> > vcat(arr_of_arr...)
> >
> > I'm asking because splatting big arrays is a performance issue (and IIRC
> it
> > blows the stack at some point).
>