julia> [foo[r] for r in some_ranges]
2-element Array{Any,1}:
 [6,2]
 [4,9]

julia> vcat([foo[r] for r in some_ranges]...)
4-element Array{Int64,1}:
 6
 2
 4
 9


Den onsdag 19 augusti 2015 kl. 04:53:55 UTC+2 skrev John Brock:
>
> Is there an easy way to slice an array using an array of ranges? I'm 
> looking for something like the following:
>
> foo = [2,6,2,8,4,9]
> some_ranges = UnitRange{Int64}[2:3, 5:6]
> foo[some_ranges] # gives error; desired output is [6,2,4,9]
>
>

Reply via email to