Previous Up Next

11.2.9  Assignment by copying: copy

The copy command creates a copy of its argument, which is typically a list of some type. If B is a list and A := B, then A and B point to the same list, and so changing one will change the other. But if A := copy(B), then A and B will point to different lists with the same values, and so can be changed individually.
Input:

B := [[4,5],[2,6]]
A := B
C := copy(B)

Output:

A, B, C

Output:

[[4,5],[2,6]],[[4,5],[2,6]],[[4,5],[2,6]]

Input:

B[1] =< [0,0]

Input:

A, B, C

Output:

[[4,5],[0,0]],[[4,5],[0,0]],[[4,5],[2,6]]

Previous Up Next