I have a simple array like this one:

myArray = {1, 2, 17}

At some point I want that 2 to be a 4. How can I change it?


closed as off-topic by mikado, Edmund, march, m_goldberg, Henrik Schumacher Oct 24 '18 at 15:03

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." – mikado, Edmund, march, m_goldberg, Henrik Schumacher
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ you can use Replace or ReplacePart... $\endgroup$ – J42161217 Oct 23 '18 at 18:05
  • 7
    $\begingroup$ myArray[[2]] = 4;. $\endgroup$ – AccidentalFourierTransform Oct 23 '18 at 18:13
  • 1
    $\begingroup$ myNewArray = MapAt[4 &, myArray, 2] $\endgroup$ – user1066 Oct 23 '18 at 19:53

Browse other questions tagged or ask your own question.