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 measure execution time in JuliaLang?
- How to sort in JuliaLang?
- How to reshape arrays in JuliaLang?
- How to read lines from file in JuliaLang?
- How to use lambda functions in JuliaLang?
- How to concatenate strings in JuliaLang?
- How to parse JSON in JuliaLang?
- How to use interpolation in JuliaLang?
- How to get JuliaLang version?
- How to test code in JuliaLang?
See more codes...