Wrong order in push! operator

The problem is that the vector a is mutated in the two inner loops (only the outermost loop creates a new vector every time). Consider the following example:

julia> v = [];

julia> a = [1,2,3];

julia> push!(v, a)
1-element Array{Any,1}:
 [1, 2, 3]

julia> a[3] = 100
100

julia> push!(v, a)
2-element Array{Any,1}:
 [1, 2, 100]
 [1, 2, 100]
3 Likes