A question about the Matrix

How do you define a matrix that doesn’t know how many rows and columns it has.
thank you!

Size isn’t part of the matrix type. Only number of dimensions. Matrix{T} will be a matrix of type T.

The best way to do this is to use a Vector of Vectors.
If you need a matrix, you can convert it at any time.


julia> vs = [ [1, 2] ]
1-element Array{Array{Int64,1},1}:
 [1, 2]

julia> push!(vs, [3, 4])
2-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]

julia> push!(vs, [5, 6])
3-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]
 [5, 6]

julia> reduce(hcat, vs)
2×3 Array{Int64,2}:
 1  3  5
 2  4  6
1 Like