Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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