I have two lists a and b of the same length. And another list a2 which contains all elements from a and some others. Now I want to construct a list b2 so that for the shared elements between a2 and a, the corresponding elements in b2 and b are the same, and for those elements in a2 but not a, the values in b2 should be placeholder 0.
Example:
a = {1, 2, 5, 8};
b = {10, 20, 50, 80};
a2 = {1, 2, 4, 5, 8, 9};
(*Output b2={10,20,0,50,80,0}*)
I know how to achieve this in C-like languages, so I'm wondering if there is a better way of doing this in Mathematica. Thanks!
P.S. a and a2 are both ordered. And no duplicate exsists in either list, if it helps.