Suppose idxs is a vector of vectors defined as
3-element Vector{Vector{Int64}}:
[1, 2]
[1, 3]
[1, 4]
And suppose A is a vector defined as
5-element Vector{Int64}:
6
7
8
9
10
With Python and numpy, I could simply do (in pseudocode) A[idxs] and this would return a 2-D array containing the elements
[
[6 7]
[6 8]
[6 9]
]
How do I perform the same indexing in Julia, where I am indexing multiple times into a 1-dimensional vector, and retrieving a matrix of entries?
Thanks
>Solution :
The easiest solution would be to use list comprehension
julia> [A[i] for i in idxs]
3-element Vector{Vector{Int64}}:
[6, 7]
[6, 8]
[6, 9]