# ReplaceAll, MapThread, Rule in sequence

**URL:** <https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683>\
**Category:** Questions\
**Created:** [October 17, 2014, 3:18pm UTC](https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683 "2014-10-17T15:18:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marferit](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@marferit](https://community.wolfram.com/u/marferit)\
**Post date:** [October 17, 2014, 3:18pm UTC](https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683/1 "2014-10-17T15:18:51Z")

</div>

Hi,  
I have

* * *

GG1 = {{1,2,3,4.},{5,6,7,8}}

* * *

result ={ {{a,b},{a,c},{a,d},{a,a}},{{a,b1},{a,c1},{a,d1},{a,a1}} }

I’d like obtain :  
res1 = { {{1,b},{2,c},{3,d},{4,a}},{{5,b1},{6,c1},{7,d1},{8,a1}} }  
the length of result or GG1 is variable depending on the test case.

I have tried with this, but it doesn’t run.

res1 = [ReplaceAll[result, MapThread[Rule, {result[[i, All, 1]], GG1[[i]] &} , {i, 1, Length[GG1]}]]]

I hope in your help

Thank you

---

<div class="post-metadata">

**Author:** ![bsimpson141421356](https://avatars.discourse-cdn.com/v4/letter/b/ac91a4/32.png) [@bsimpson141421356](https://community.wolfram.com/u/bsimpson141421356)\
**Post date:** [October 17, 2014, 3:58pm UTC](https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683/2 "2014-10-17T15:58:33Z")

</div>

Map[Transpose, Transpose[{GG1, Map[Last, result, {-2}]}]]

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [October 17, 2014, 4:03pm UTC](https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683/3 "2014-10-17T16:03:57Z")

</div>

In[17]:= MapThread[List, {GG1, result[[All, All, 2]]}, 2]

Out[17]= {{{1, b}, {2, c}, {3, d}, {4, a}}, {{5, b1}, {6, c1}, {7,  
d1}, {8, a1}}}

---

<div class="post-metadata">

**Author:** ![marferit](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@marferit](https://community.wolfram.com/u/marferit)\
**Post date:** [October 17, 2014, 5:07pm UTC](https://community.wolfram.com/t/replaceall-mapthread-rule-in-sequence/3683/4 "2014-10-17T17:07:39Z")

</div>

Thank you
