Re: Changing a list with the information of other
- To: mathgroup at smc.vnet.net
- Subject: [mg131425] Re: Changing a list with the information of other
- From: Themis Matsoukas <tmatsoukas at me.com>
- Date: Wed, 3 Jul 2013 22:04:02 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
Here is one way:
a = {{0, 1}, {1, w}, {2, 1 + w}, {3, 1 + 2 w}, {4, 2}, {5, 2 w}, {6,
2 + 2 w}, {7, 2 + w}};
b = {1, 1 + w, 2 + w, 2 w, 2, 2 + 2 w, 1 + 2 w, w};
Apply[#1 &,
Flatten[Table[Select[a, #[[2]] == b[[i]] &, 2], {i, 1, b // Length}],
1], 1]
{0, 2, 7, 5, 4, 6, 3, 1}