Literal expression for array of vectors

Right. That still requires one extra “mental step” to look at the flat vector and the dimensions and conclude that the resulting shape makes sense.

I think I am looking for some literal syntax that preserves the “visual shape” of the matrix. With reshape I can kind of make it work, but one has to take care about the right order of the dimensions (that’s exactly the extra mental step I wanted to avoid :sweat_smile: )

E.g. this is one of the matrices that I am actually testing in my code (the eltype is not relevant for this test):

5×2 Matrix{Vector{Any}}:
 [1]  [2]
 [3]  []
 []   []
 []   []
 [4]  []

This is how I would like to write it with reshape (to get visually similar to the REPL output):

julia> reshape([
           [1], [2],
           [3], [ ],
           [ ], [ ],
           [ ], [ ],
           [4], [ ],
       ], (5, 2))
5×2 Matrix{Vector{Any}}:
 [1]  []
 [2]  []
 [3]  []
 []   [4]
 []   []

But of course it’s not right, since the vector elements are parsed in column-major order. So I would need an additional transpose:

julia> reshape([
           [1], [2],
           [3], [ ],
           [ ], [ ],
           [ ], [ ],
           [4], [ ],
       ], (2, 5)) |> permutedims
5×2 Matrix{Vector{Any}}:
 [1]  [2]
 [3]  []
 []   []
 []   []
 [4]  []

This is kind of clunky, but probably good enough for me.