# Generate a list of rules from two rules

I have two lists:

a = {a1,a2,a3}
b = {b1,b2,b3}


and I want to generate a list of replacement rules

r = {a1->b1,a2->b2,a3->b3}


I would have thought I could simply do

r = #1->#2&/@[a,b]


But this produces no output. This is such a simple operation I'm sure there's something very straightforward. I could of couse use a Table, but I'm sure there's an easy and elegant method I'm missing.

• Because /@ is Map , so one way is to #1->#2&[a,b] , but is not what you want. (#[[1]] -> #[[2]] &) /@ {{a1, a2}, {b1, b2}} partly works.Not elegant. So you may want this (#[[1]] -> #[[2]] &) /@Transpose@ {a, b} Jul 9, 2020 at 7:50

Thread[ a -> b]

 {a1 -> b1, a2 -> b2, a3 -> b3}


Also:

Inner[Rule, a, b, List]

 {a1 -> b1, a2 -> b2, a3 -> b3}


and

# -> #2 & @@@ Transpose[{a, b}]

 {a1 -> b1, a2 -> b2, a3 -> b3}

Rule @@@ Transpose[{a, b}]

 {a1 -> b1, a2 -> b2, a3 -> b3}