# Condition syntax: “when equal to any of”

I am trying to write a condition clause for a certain expression. I need to pick out the following cases:

Mod[x*y, 10] == 8, or

Mod[x*y, 10] == 3, or

Mod[x*y, 10] == 7.

I need to repeat this three times, and both x and y are actually complex expressions, so it would be nice to be able to write this in a compact way.

I have tried

Mod[x*y, 10] == Or[8,3,7]


but this doesn't seem to work.

You can use any of the following:

MatchQ[Mod[x y, 10], 8 | 3 | 7]
MemberQ[{8, 3, 7}, Mod[x y, 10]]
AnyTrue[{8, 3, 7}, Mod[x y, 10] == # &]
Or @@ (Mod[x y, 10] == # & /@ {8, 3, 7})


Here's another method that's quite close to what you tried at first:

Thread[Mod[x*y, 10] == Or[8, 3, 7], Or]


Note, however, that this won't work if any of the arguments of Or are boolean since this method relies on Or not evaluating.