julialangHow to create an array in JuliaLang?
An array in JuliaLang is a collection of elements of the same type. It can be created using the Array
function.
Example
julia> a = Array{Int64,1}(undef, 3)
3-element Array{Int64,1}:
#undef
#undef
#undef
The code above creates an array of type Int64
with length 3.
The Array
function takes two arguments:
- The type of the elements in the array.
- The dimensions of the array.
For example, to create a 2-dimensional array of type Float64
with 3 rows and 4 columns, the code would be:
julia> b = Array{Float64,2}(undef, 3, 4)
3×4 Array{Float64,2}:
#undef #undef #undef #undef
#undef #undef #undef #undef
#undef #undef #undef #undef
Helpful links
More of Julialang
- How to append to an array in JuliaLang?
- How to get JuliaLang version?
- How to measure execution time in JuliaLang?
- How to use tuples in JuliaLang?
- How to add a legend to a plot in JuliaLang?
- How to sort in JuliaLang?
- How to test code in JuliaLang?
- How to use try catch in JuliaLang?
- How to use the JuliaLang package manager?
- How to round numbers in JuliaLang?
See more codes...