julia数组是否支持具有多个范围的索引,如下所示
dat = Array(1:10)
# trying to get dat[[1:3, 6:8]] to result in
dat[[1,2,3,6,7,8]]
Run Code Online (Sandbox Code Playgroud)
寻找像R等价的东西dat[c(1:3, 6:8)]
?
R版本的直接等价物是
v = 1:10
v[ [1:3; 6:8] ]
Run Code Online (Sandbox Code Playgroud)
因为;
是连接运算符:
julia> [1:3; 6:8]
6-element Array{Int64,1}:
1
2
3
6
7
8
Run Code Online (Sandbox Code Playgroud)
您可能还想查看chain
Iterators.jl包:https://github.com/JuliaLang/Iterators.jl