Julia Vectors

Vectors are a columnar series of values.


Description

Vectors are instantiated like:

julia> a = [1,2,3]
3-element Vector{Int64}:
 1
 2
 3

Vectors cannot ordinarily be created from a range, but using the vertical concatenation operator (;) can be a trick to make it work anyway. Consider:

julia> a = [1:3]
1-element Vector{UnitRange{Int64}}:
 1:3

julia> a = [1:3; ]
3-element Vector{Int64}:
 1
 2
 3

Typing

Vectors are required to be a collection of values that are of the same type. If those values are not of the same type but have a common promotion type, they are type cast.

julia> a = [1, 2.3, 4//5]
3-element Vector{Float64}:
 1.0
 2.3
 0.8

The values can also be explicitly type cast when instantiated.

julia> Float32[1, 2.3, 4//5]
3-element Vector{Float32}:
 1.0
 2.3
 0.8

The Vector type itself descends from AbstractArray, just like the Matrix type.


CategoryRicottone