1
I wonder if it is possible to identify if a matrix is inside another javascript matrix.
For example, if the matrix A is inside B or C inside A.
I’m trying to apply the following code:
a = [[1,2],[5,4]]
c = [[2,4],[10,8], [1, 2], [5,4]]
function compare(first, last)
{
var result = first.filter(function(item){ return last.indexOf(item) > -1});
return result.length;
}
console.log(compare(a, c) === a.length);
In this case you want to compare if two matrices are equal, no? Although your code does not reflect the image. Where the matrix B in the code?
– Luiz Felipe
in the case I did I wouldn’t have B, but A is inside C
– Guilherme
In this case then you want to return a boolean (true or false) according to the query "
a
is insidec
"?– Luiz Felipe
that’s right, that would be the answer
– Guilherme