How to convert Vector of Vectors to Matrix

Don’t use splatting (...) of large arrays, e.g. don’t use things like hcat(x...). Use reduce, e.g. reduce(hcat,x) as suggested above.

Update: In Julia 1.9 or later, use the stack function, e.g. stack([[1,0,1],[ 0,0,1]], dims=1) == [ 1 0 1 ; 0 0 1 ].

13 Likes