Previous Up Next

12.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.


Example.
Input:

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

Output:



45
26


,

45
26


,

45
26


Input:

B[1] =< [0,0]
A, B, C

Output:



45
00


,

45
00


,

45
26



Previous Up Next