05-08-2017 04:37 PM
Hello,
I am trying to compare two arrays (one is larger than the other). Whenever two elements match in value I would like to delete this element from the larger array. The result being an output array that has no elements similar to the smaller array.
As an example:
large = [1,3,5,7,9]
small = [2,3,4,5]
output = [1,7,9]
In my case there are no repeated values and they are always increasing with the indices. Also, my large array has about 150 elements. I've been playing around with shift registers and for loops to no avail and am hoping for some guidance.
At this point I don't think posting any of my past attempts will help, but I can if you need it.
Thank you.
Solved! Go to Solution.
05-08-2017 04:39 PM
What's your definition of "similar"? Are the arrays integer of floating point?
05-08-2017 04:47 PM
They are arrays of integers. And by similar I mean equivalent. I was being too loose with my words.
05-08-2017 06:30 PM - edited 05-08-2017 06:36 PM
Maybe something like that?
(Since the large array does not have repeated elements, you can add a +1 before going to the F terminal of the select node.. Probably not worth it. For smaller arrays you can even simplify and just brute-force search from the beginning with every iteration, eliminating the shift register and such, see below. For large arrays, it will be less efficient, because the first element of the small array will be inspected N times)
05-09-2017 09:08 AM
This works perfectly, just what I need.
Thank you.