Index array with multiple ranges

arrays, julia

Solution

The direct equivalent of the R version is

v = 1:10
v[ [1:3; 6:8] ]

since `;` is the concatenation operator:

julia> [1:3; 6:8]
6-element Array{Int64,1}:
 1
 2
 3
 6
 7
 8

You may also want to look at `chain` in the Iterators.jl package: https://github.com/JuliaLang/Iterators.jl

Problem

Do julia arrays support indexing with multiple ranges like the following ``` dat = Array(1:10) # trying to get dat[[1:3, 6:8]] to result in dat[[1,2,3,6,7,8]] ``` Looking for something that would be like the R equivalent `dat[c(1:3, 6:8)]`?

Original source