'Can we have Matrix of vectors in julia?

Can we form a julia matrix whose elements are vectors? I have tried the following but it only formed matrix of Int.

julia> [[1, 2] [2, 3]; [4, 5] [3, 5]]
4×2 Matrix{Int64}:
1  2
2  3
4  3
5  5

But I wanted [1, 2] to be the first element not 1. Is it possible?



Solution 1:[1]

Here is one way to do it:

julia> [[[1, 2]] [[2, 3]]; [[4, 5]] [[3, 5]]]
2×2 Matrix{Vector{Int64}}:
 [1, 2]  [2, 3]
 [4, 5]  [3, 5]

another would be:

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

but maybe there is some better solution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bogumił Kamiński