I am wondering if there's a neat way to compare (!= or ==) several values in an array (so multiple indices) with several values (multiple indices) in another array. Let me explain a little more in-depth.
I have a continuous list input to a function, where I want to add the lists as "rows" to my data array, so something like this:
var data = new Array();
function compare() {
// lets say all the input lists have 4 elements, example [100, 200, 300, 400].
var input_list = arrayfromargs(arguments);
// concat the input with my data variable.
data = data.concat([input_list]);
}
However, I do NOT want to add the input list as a row to the data array if there already exists a row in the data array with the same values at specific indices.
For instance, say I want to compare values at the last and second-to-last indices (so index 2 and 3 (values 300 and 400) in the example above). How can I best compare my input list values at the 2nd and 3rd index to every value at the 2nd and 3rd index in the data array rows?
I know that the most obvious way is to have nested if-else's inside a for-loop, however, this quickly becomes quite messy.
Any more refined or elegant ways to accomplish this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…