Suppose I have a list A={x1,x2,x3}, a list B={3,4,5}, and a function f[x]=x1+x2+x3. Is there a simple way to create a replacement rule R such that I can do a f[x]/.R to get 3+4+5?


1 Answer 1


Yes, there is a simple way: Thread.

x1 + x2 + x3 /. Thread[A -> B]

Other ways to create the list of replacement rules include

Rule @@@ Transpose[{A, B}]
MapThread[Rule, {A, B}]
Inner[Rule, A, B, List]

Or less obvious


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.