Suppose I have two arrays:
a = [2, 4, 6, 7, 10, 11]
b = [6, 7, 10, 11, 13, 15, 17, 19, 21, 23]
How do I get the indices of values in b
that are in a
and vice versa? I know intersection()
returns the values, but I’m after the indices of the two arrays. Right now I’m doing
indices = [findall(x->x==i,a) for i in b]
10-element Array{Array{Int64,1},1}:
[3]
[4]
[5]
[6]
[]
[]
[]
[]
[]
[]
which doesn’t seem optimal. Any ideas? Thanks in advance!