array-difference
Difference between two numpy arrays in python
This is pretty simple with numpy, just subtract the arrays: diffs = array1 – array2 I get: diffs == array([ 0.1, 0.2, 0.3])
Compare 2 arrays which returns difference
I know this is an old question, but I thought I would share this little trick. var diff = $(old_array).not(new_array).get(); diff now contains what was in old_array that is not in new_array
“Array to string conversion error” when calling array_diff_assoc() with a multidimensional array
According to it: php -r ‘array_diff(array(“a” => array(“b” => 4)), array(1));’ PHP Notice: Array to string conversion in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. array_diff() Command line code:1 One of your arrays is multidimensional. array_diff only checks one dimension of a n-dimensional array. Of … Read more
Subtracting one Array from another in Ruby
You can subtract arrays in Ruby: [1,2,3,4,5] – [1,3,4] #=> [2,5] ary – other_ary → new_ary Array Difference Returns a new array that is a copy of the original array, removing any items that also appear in other_ary. The order is preserved from the original array. It compares elements using their hash and eql? methods … Read more
How to get the difference between two arrays in JavaScript?
There is a better way using ES7: Intersection let intersection = arr1.filter(x => arr2.includes(x)); For [1,2,3] [2,3] it will yield [2,3]. On the other hand, for [1,2,3] [2,3,5] will return the same thing. Difference let difference = arr1.filter(x => !arr2.includes(x)); For [1,2,3] [2,3] it will yield [1]. On the other hand, for [1,2,3] [2,3,5] will … Read more