November 2017
Beginner
316 pages
6h 40m
English
Although the size of the array is fixed, Julia provides certain functions that can be utilized to alter the length of the array. Let's create an empty array and add values to it:
# this creates an empty arrayjulia> empty_array = Float64[]0-element Array{Float64,1}# the function push!() adds values to the arrayjulia> push!(empty_array,1.1)1-element Array{Float64,1}:1.1
We can keep on adding values:
julia> push!(empty_array,2.2,3.3)3-element Array{Float64,1}:1.12.23.3
Adding values one by one may not suit the purpose. There is another way to add values to the array using the append!() function. Using append!(), we can add all the items of another collection to our collection:
julia> append!(empty_array,[101.1,202.2,303.3]) ...
Read now
Unlock full access