-
To format code wrap it between triple ticks:
```
at the beginning and at the end
```Will look like this:
at the beginning and at the end -
This is not aboout global variables. When you do An = A you are giving a new name (An) to the same object in memory as A. So when you modify one you modify the other one as well.
You want to do:
An = copy(A)
This behavior is mentioned for example in the second point of this list: Noteworthy Differences from other Languages · The Julia Language
By the way this works the same in python, maybe you were thinking Matlab?:
In [3]: a = [[1, 1, 1], [2, 2, 2]]
In [4]: a
Out[4]: [[1, 1, 1], [2, 2, 2]]
In [5]: a1 = a
In [6]: a1[1][1] = 5
In [7]: a1
Out[7]: [[1, 1, 1], [2, 5, 2]]
In [8]: a
Out[8]: [[1, 1, 1], [2, 5, 2]]