0

I would like to understand why in this code :

    For[k = 1, k <= Length[Couples1],
  j3[k][[1]] = 6;
  j3[k][[2]] = 7;
  Print[j3[k][[1]]];
  k++;

  ];

1

2

3

4

5

6

7

8

9

My variable j3[k][[1]] isn't affected to "6" ? It is just a code of example but I don't get why it does'nt work ?

StarBucK
  • 2,164
  • 1
  • 10
  • 33
  • The linked duplicate discuss j3[[k]][[1]] example while you have j3[k][[1]] but the issue is the same and should answer your problem. Let me know if you disagree. Also see the second link from comment and links from it to learn more if you want. – Kuba Jun 18 '17 at 21:17
  • Thank you. I understood that Part is a too low level function to allows this. I can thus use AppendTo in my example. But Is there another function of "higher level" than part to allow me to do the same thing as j3[k][[1]] = 6; ? – StarBucK Jun 19 '17 at 11:55
  • E.g. j3[k] = ReplacePart[j3[k], 1 -> 6] – Kuba Jun 23 '17 at 06:43

0 Answers0