I want to compare two arrays, using pattern matching. For example, suppose:
a1 = {{0, 0, 1}, {0, 0, 1}, {0, 0, 1}};
I would like to compare it to the pattern array:
p = {{0, 0, x}, {0, 0, 1}, {0, 0, 1}};
that is, here x is arbitrary - it can take any value. So I would like to do something like:
a1==p
and have it return true. If however,
a1 = {{0, 1, 1}, {0, 0, 1}, {0, 0, 1}};
then
a1==p
would return false.
I have about 12 different pattern matching arrays that I need to define, and then compare a given array to each pattern to the find which pattern that array follows. Some entries of the pattern are fixed, other are arbitrary. Another pattern array would look like:
p2 = {{0, 0, x}, {0, 0, 1}, {x, 1, 1}};
that is, as long as the 1's and 0's are in the same position, then the arrays are the same.
I'm not the most familiar with pattern matching coding in mathematica, I apologise if the solution is actually trivial as it is given in the function references within mathematica. Thanks in advance.