I have two arrays of elements say, A = {1, 2} and B = {3, 4} for a working example. The way they are generated in a multi-step process, there is no control over the order of elements. So A may also be {2, 1} and so is true for B.
Now I want to create one-to-one thread from A → B, which would give o/p either {1-> 3, 2-> 4} or {1-> 4, 2-> 3}. By using Permutations[B] in stead of B, one can generate all possible threads.
Now I want to pick one of those, which is more likely. For above example, I know that 1-> 4 is more likely than 1-> 3 so the correct thread would be the one with it so {1-> 4, 2-> 3} should be preferred over {1-> 3, 2-> 4} as o/p. Now my question is how to do this mathematically. How to tell mathematical that out of n possible elements in an table, pick one over all others (n-1) depending upon the preference of i->j present in the elements. Following is the code for working example. SelectFirst seems to be a good choice for doing it, but I could not code the condition part properly.
Will appreciate any help on this, or any other alternative function to get this done. Thanks
A = {1, 2};
B = {3, 4};
BB = Permutations[B];
CC = Table[Thread[A -> BB[[i]]], {i, 1, Length[B]}]
(1) Is there an option opposite to “Select”, which can leave out the options according to the Rule, rather than selecting. (Otherwise one can always subtract the o/p of “Select” from original string to get this effect)
(2) Also, I want to set preferences. So that if I use Rule[3, 1], I get o/p without it if possible, if not, I get one with it. On the contrary “Select” completely bars the Rule and if there is no possible o/p without 3->1, I get null o/p. I don’t want this.
Hope I am able to explain both my points. Will appreciate you suggestion on them.