### 25.2.10 Difference between operators := and =<

The := and =< assignment operators have different effects when they are used to modify an element of a list contained in a variable, since =< modifies the element by reference. Otherwise, they will have the same effect.

#### Example

A:=[1,2,3]

Now

A[1]:=5

and

A[1]=<5

both change A[1] to 5:

A

| ⎡ ⎣ | 1,5,3 | ⎤ ⎦

but they do it in different ways. The command A[1]=<5 changes the middle value in the list that A originally pointed to, and so any other variable pointing to the list will be changed, but A[1]:=5 will create a duplicate list with the middle element of 5, and so any other variable pointing to the original list won’t be affected.

#### Examples

A:=[0,1,2,3,4]:; B:=A:; B[3]=<33:; A,B

| ⎡ ⎣ | 0,1,2,33,4 | ⎤ ⎦ | , | ⎡ ⎣ | 0,1,2,33,4 | ⎤ ⎦

A:=[0,1,2,3,4]:; B:=A:; B[3]:=33:; A,B

| ⎡ ⎣ | 0,1,2,3,4 | ⎤ ⎦ | , | ⎡ ⎣ | 0,1,2,33,4 | ⎤ ⎦

If B is set equal to a copy of A instead of A, then changing B won’t affect A.

A:=[0,1,2,3,4]; B:=copy(A); B[3]=<33; A,B

| ⎡ ⎣ | 0,1,2,3,4 | ⎤ ⎦ | , | ⎡ ⎣ | 0,1,2,33,4 | ⎤ ⎦