1
$\begingroup$

Question

So, for example, I have the code here:

initialXArr = {Subscript[x, 0][0], Subscript[x, 1][0], 
  Subscript[x, 2][0], Subscript[x, 3][0], Subscript[x, 4][0]}

xarr = {15, 16, 17, 18, 19}

So I have two arrays now equal to the stuff above. I want code that is able to combine the two lists into one and just output the following list:

{Subscript[x, 0][0] == 15, Subscript[x, 1][0]==16, 
 Subscript[x, 2][0] == 17, Subscript[x, 3][0] == 18, 
 Subscript[x, 4][0] == 19}

I do not want to evaluate anything, I just need the output to the the above.

What I've Tried

Just setting the arrays equal. I just get False back.

{Subscript[x, 0][0], Subscript[x, 1][0], 
      Subscript[x, 2][0], Subscript[x, 3][0], Subscript[x, 4][0]} == {Subscript[x, 0][0] == 15, Subscript[x, 1][0]==16, 
     Subscript[x, 2][0] == 17, Subscript[x, 3][0] == 18, 
     Subscript[x, 4][0] == 19}

This is the only thing I've tried as of now. Honestly, I don't know where to begin trying solutions. This seems like an unusual thing to be trying to get Mathematica to do.

Notes

  • If possible, I would like this code to be extendable to any two lists with matching numbers of entries.

I really appreciate any help I can have on this issue. Thank you very much!

$\endgroup$

closed as off-topic by Jens, MarcoB, m_goldberg, user9660, ubpdqn May 12 '16 at 10:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Jens, MarcoB, m_goldberg, Community, ubpdqn
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ @ciao, I just added things I've tried. $\endgroup$ – jackskis May 8 '16 at 4:50
  • $\begingroup$ Also, @ciao-- I see plenty of straight up questions get answered here with little to no background. I think the way I've phrased this question is within the bounds of how to ask a question detailed in the How do I ask a good question? section... $\endgroup$ – jackskis May 8 '16 at 5:08
  • 3
    $\begingroup$ "If possible, I would like this code to be extendable to any two lists with matching numbers of entries. " - but your example does not, how should that be interpreted? For equal-length lists, Thread[initialXArr == xarr] should do the trick. Word of warning - avoid subscripting for other than display, in general... $\endgroup$ – ciao May 8 '16 at 5:19
  • $\begingroup$ Your arrays are not of equal length. One is 4 long and the other is 5 long. Also, what is the logic for skipping Subscript[x, 1][0] in the combination. Or is this a typo. $\endgroup$ – Edmund May 8 '16 at 13:02
  • 1
    $\begingroup$ The reason you got False is probably because the elements of inintalXArr had been assigned values previously, perhaps by inadvertently using = instead of ==. $\endgroup$ – Jens May 8 '16 at 16:21
3
$\begingroup$

Try this:

MapThread[Equal, {initialXArr, xarr}]

(*  {Subscript[x, 0][0] == 15, Subscript[x, 1][0] == 16, 
 Subscript[x, 2][0] == 17, Subscript[x, 3][0] == 18, 
 Subscript[x, 4][0] == 19}  *)

Have fun!

$\endgroup$

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