In Julia, the ; may be used to create a two-dimensional array.
julia> [1 2; 3 4]
2x2 Array{Int64,2}:
 1  2
 3  4
Is it possible to use a similar syntax to create a three-dimensional (or higher-dimensional) array? The following works, but I am unsure as to whether or not there is a cleaner, better way.
julia> reshape(collect(1:8), 2, 2, 2)
2x2x2 Array{Int64,3}:
[:, :, 1] =
 1  3
 2  4
[:, :, 2] =
 5  7
 6  8
                I suppose the cleanest manual syntax is via the cat command, e.g.:
cat(3, [1 2 ;3 4], [5 6 ; 7 8]);   % concatenate along the 3rd dimension
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With