Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say you have two lists:

listA = {a, b, c}

listB = {d, e, f}

How would you produce a listC that equates each of the two's elements, ie.

listC = {a == d, b == e, c == f} ?

I know, it's very easy, but somehow I've already spent an slightly embarrassing amount of time on this. I suspect it will involve Map, but can't seem to get the elements to behave together per each element. It seems to just Append the two together for some reason.

SetAttributes[listA, Listable] SetAttributes[listB, Listable]

seems promising given this:

share|improve this question
Thread[listA == listB] – R. M. Jun 12 '13 at 0:45
@rm -rf thank you – Ghersic Jun 12 '13 at 0:47
Can you answer your own question now, using rm's hint? – J. M. Jun 12 '13 at 2:22
@rm-rf If listA is equal to listB, then Thread[listA == listB] will return just True. In that case, this: MapThread[Equal, {listA, listB}]. – Michael E2 Jun 12 '13 at 5:37
up vote 7 down vote accepted

As @rm -rf mentioned in the comments,

Thread[listA == listB]

accomplishes what I'd hoped. Apoogies for missing this.

As Michael notes, if they are already equal to these values (you're not newly naming listA or listB) and they happen to already be equal , the query just returns "true." If this is the case, use:

MapThread[Equal, {listA, listB}]

as mentioned by MichaelE2 in the comments.

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.