I have a piece of code (which I believe is very inefficient and bad; I may be wrong though.), that checks whether a variable is in range determined by some other variables, like so;
if ((a >= (x.eq(0) && y.eq(0)) || (a >= x.eq(1) && y.eq(1)) ... || (a >= x.eq(n) && y.eq(n)))) {
// code here
}
(I might have gotten the amount of brackets wrong in the question, but the code itself works.)
where n is the total amount of numbers in arrays x and y.. Obviously, the if condition looks very, very large and I believe it's unoptimized and "bad". Is there anything I can use to make the condition shorter? In case the block above is unreadable, what I want in pseudocode:
Check if a is between x(0) and y(0).
If true, do things.
Else check if a is between x(1) and y(1).
If true, do things.
Else check ... if a is between x(n) and y(n).
If true, do things.
Else do nothing.