Suppose I have the following 4x4 Array in Julia:
julia> A=rand(4,4)
4×4 Array{Float64,2}:
0.00624508 0.624399 0.458094 0.341848
0.303817 0.269487 0.580949 0.534655
0.748525 0.419411 0.469938 0.659914
0.730659 0.191461 0.996144 0.74772
And I have another 6x2 Array where each row represents a row-column pair:
julia> B=[ 1 1; 1 3; 2 2; 2 4; 3 1; 3 3]
6×2 Array{Int64,2}:
1 1
1 3
2 2
2 4
3 1
3 3
The first row of B represents the element [1,1] of A, the second row of B represents the element [1,3] of A, and so on. I want to access the elements of A based on the coordinates given by each row of B. In R for example, the command A[B] gives exactly what I want: 0.00624508 0.458094 0.269487 0.534655 0.748525 0.469938 but in Julia, the same command gives
julia> A[B]
6×2 Array{Float64,2}:
0.00624508 0.00624508
0.00624508 0.748525
0.303817 0.303817
0.303817 0.730659
0.748525 0.00624508
0.748525 0.748525
and this is not what I want. Is there a similar way of coding A[B] in Julia, so that I obtain what I obtain in R? Must be applicable to any Array.