# Changing Elements Problem in Combinations of Any Array

**URL:** <https://discourse.julialang.org/t/changing-elements-problem-in-combinations-of-any-array/111355>\
**Category:** General Usage\
**Tags:** question, arrays\
**Created:** [March 8, 2024, 1:05pm UTC](https://discourse.julialang.org/t/changing-elements-problem-in-combinations-of-any-array/111355 "2024-03-08T13:05:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umut\_Can\_Turhan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/umut_can_turhan/32/49221_2.png) [@Umut\_Can\_Turhan](https://discourse.julialang.org/u/Umut_Can_Turhan)\
**Post date:** [March 8, 2024, 1:05pm UTC](https://discourse.julialang.org/t/changing-elements-problem-in-combinations-of-any-array/111355/1 "2024-03-08T13:05:32Z")

</div>

Assume that I’ve created an permutation array:

```julia
sample = [0,0],[1,0],[0,1]
Per_arr = [[α,β] for α in sample for β in sample]

```

```julia
# Output
9-element Vector{Vector{Vector{Int64}}}:
 [[0, 0], [0, 0]]
 [[0, 0], [1, 0]]
 [[0, 0], [0, 1]]
 [[1, 0], [0, 0]]
 [[1, 0], [1, 0]]
 [[1, 0], [0, 1]]
 [[0, 1], [0, 0]]
 [[0, 1], [1, 0]]
 [[0, 1], [0, 1]]

```

When I try to change element of `sample` matrices,

```julia
changed_arr = Per_arr[2]
chg[2][1] = 0

```

```julia
# Output
9-element Vector{Vector{Vector{Int64}}}:
 [[0, 0], [0, 0]]
 [[0, 0], [0, 0]]
 [[0, 0], [0, 1]]
 [[0, 0], [0, 0]]
 [[0, 0], [0, 0]]
 [[0, 0], [0, 1]]
 [[0, 1], [0, 0]]
 [[0, 1], [0, 0]]
 [[0, 1], [0, 1]]

```

All the other elements that are the same as changed\_arr are changed! I want to change just specific elements of array while the other remains same. In conclusion, elements of permutated array are not individual, they are coupling elements. When I change the one element, the other same element that I changed one will be change.

How is this possible? What is the basic/efective solution?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 8, 2024, 1:08pm UTC](https://discourse.julialang.org/t/changing-elements-problem-in-combinations-of-any-array/111355/2 "2024-03-08T13:08:55Z")

</div>

> [@Umut\_Can\_Turhan](#):
>
> `Per_arr = [[α,β] for α in sample for β in sample]`

you need `Per_arr = [[copy(α),copy(β)] for α in sample for β in sample]`
