julia数组操作示例代码
代码语言:julia
所属分类:其他
代码描述:julia数组操作示例代码
代码标签: 示例
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
function printsum(a) # summary generates a summary of an object println(summary(a), ": ", repr(a)) end # arrays can be initialised directly: a1 = [1,2,3] printsum(a1) #> 3-element Array{Int64,1}: [1, 2, 3] # or initialised empty: a2 = [] printsum(a2) #> 0-element Array{Any,1}: Any[] # since this array has no type, functions like push! (see below) don't work # instead arrays can be initialised with a type: a3 = Int64[] printsum(a3) #> 0-element Array{Int64,1}: Int64[] # ranges are different from arrays: a4 = 1:20 printsum(a4) #> 20-element UnitRange{Int64}: 1:20 # however they can be used to create arrays thus: a4 = collect(1:20) printsum(a4) #> 20-element .........完整代码请登录后点击上方下载按钮下载查看
网友评论0