- Julia 1.0 Programming Complete Reference Guide
- Ivo Balbaert Adrian Salceanu
- 125字
- 2021-06-24 14:21:43
Other ways to create arrays
For convenience, zeros(n) returns an n element array with all the elements equal to 0.0, and ones(n) does the same with elements equal to 1.0.
range(start, stop=value, length=value) creates a vector of n equally spaced numbers from start to stop, for example, as follows:
eqa = range(0, step=10, length=5) #> 0:10:40
show(eqa) #> 0:10:40
You can use the following to create an array with undefined values #undef, as shown here:
println(Array{Any}(undef, 4)) #> Any[#undef,#undef,#undef,#undef]
To fill an array arr with the same value for all the elements, use fill!(arr, 42), which returns [42, 42, 42, 42, 42].
To create a five-element array with random Int32 numbers, execute the following:
v1 = rand(Int32,5) 5-element Array{Int32,1}: 905745764 840462491 -227765082 -286641110 16698998
推薦閱讀
- JavaScript從入門到精通(微視頻精編版)
- Learning C# by Developing Games with Unity 2020
- Mastering OpenCV Android Application Programming
- Python自動(dòng)化運(yùn)維快速入門(第2版)
- 編程菜鳥學(xué)Python數(shù)據(jù)分析
- 微服務(wù)架構(gòu)深度解析:原理、實(shí)踐與進(jìn)階
- C語言程序設(shè)計(jì)
- C#開發(fā)案例精粹
- Java Fundamentals
- Principles of Strategic Data Science
- 人工智能算法(卷1):基礎(chǔ)算法
- Mastering Apache Storm
- Struts 2.x權(quán)威指南
- Learning Splunk Web Framework
- Greenplum構(gòu)建實(shí)時(shí)數(shù)據(jù)倉庫實(shí)踐