""" undo the effect of `vcat(xs...)` """ function un_vcat(x::AbstractVector{T}, dim::AbstractVector{Int}) where {T} N = length(dim) xs = Array{AbstractVector{T}}(undef, N) for n=1:N i0 = sum(dim[1:(n-1)]) xs[n] = x[(i0+1) : (i0 + dim[n])] end return xs end using Test: @test, @inferred x1 = 1:4; x2 = ones(5); x3 = [7,6] dim = [length(x1), length(x2), length(x3)] x = vcat(x1, x2, x3) xs = @inferred un_vcat(x, dim) @test xs == [x1, x2, x3]