# List to list transformation rules

GROUPS:
 Hello, Here is an oversimplified list : {x,x,x} and a list of transformation rules : {x->a, x->b, x->c}. What I need : to apply the first rule to the first element, the second rule to the second element and so on. Expected result : {a,b,c}A neat way to do this ?Thanks in advance, Andre
19 days ago
7 Replies
 Frank Kampas 1 Vote In[11]:= Inner[ReplaceAll, {x, x, x}, {x -> a, x -> b, x -> c}, List]Out[11]= {a, b, c}
19 days ago
 Frank Kampas 1 Vote Another approach In[12]:= MapThread[ReplaceAll, {{x, x, x}, {x -> a, x -> b, x -> c}}]Out[12]= {a, b, c}
19 days ago
 Andre Hautot 1 Vote The first solution sligthly less time-consuming, Many thanks, Andre
 Hello Andre, this is a little faster approach: In[11]:= ReplaceAll[{x, x, x}, {x__} -> { a, b, c}]Out[11]= {a, b, c}Here, the result is independent from the list (input) because of _ _ (blank sequence). For example: In[12]:= ReplaceAll[{x, y, z}, {x__} -> { a, b, c}]Out[12]= {a, b, c}
 If the oversimplified list is always of that form then a simple transformation is: In[32]:= x /. Partition[{x -> a, x -> b, x -> c}, 1]Out[32]= {a, b, c}
 Or if there's no transformation at all: {x -> a, x -> b, x -> c}[[All, 2]]{a, b, c}