Check if a combination of values exists across two rows

How can I check if a vector, say A, contains a particular value, and another vector, say B, contains another particular value - in the same row as the value was found in vector A? For example:

Target value in A is 9
Target value in B is 7

A = [1;2;3;9]
B = [8;1;2;7]

How can I check that the combination 9 and 7 exists?

How about

C = reduce(&, hcat(A, B) .== [9 7], dims=2)
4×1 BitArray{2}:
 0
 0
 0
 1

If you want the index, you can use

findall(C)
1-element Array{CartesianIndex{2},1}:
 CartesianIndex(4, 1)

zip is probably good for this

julia> x = [1, 2, 3]
3-element Array{Int64,1}:
 1
 2
 3

julia> y = [4, 5, 6]
3-element Array{Int64,1}:
 4
 5
 6

julia> (3, 6) in zip(x, y)
true
2 Likes

also, use , instead of ;

1 Like