Anonymous user
Create a two-dimensional array at runtime: Difference between revisions
Create a two-dimensional array at runtime (view source)
Revision as of 16:33, 5 January 2018
, 6 years agoAdded Julia language
(→{{header|Rust}}: switch to `vec` macro) |
(Added Julia language) |
||
Line 1,136:
Julia supports n-dimensional arrays as native data types: `Array{T, N}`, where `T` is the type of it´s elements and `N` is the number of dimensions.
<lang julia>function input(prompt::AbstractString)
end
▲ print(prompt)
▲ chomp(readline())
x -> parse(Int, x)
m = input("Upper bound for dimension
x -> parse(Int, x)
x = rand(n, m)
display(x)
▲julia> x[3, 3] # overloads `getindex` generic function
▲julia> x[3, 3] = 5 # overloads `setindex!` generic function
▲julia> x::Matirx # `Matrix{T}` is an alias for `Array{T, 2}`
▲julia> x = 0; gc() # Julia has no `del` command, rebind `x` and call the garbage collector
Manually calling the garbage collector may or may not actually collect the array, but it will be eventually.
|