Question: why is a procedure changing the input?

I have a procedure that changes the value of an input variable quite unexpectdly. Can anyone explain why? I have a very simplified example of this below.

restart;
with(LinearAlgebra):
switch := proc (V::Vector)
description "This procedure is supposed to take a Vector V and switch entries 1 and 2";
local W,a,b;
W:= V;
a:= W[1];
b:= W[2];
W[1 ] := b;  
W[2] :=a;
W
end proc;

V1:=Vector([1,3,5]);
V2:=switch(V1);
I have omitted the output for brevity's sake but all works well as expected.
However,
V1;

returns V2 not V1. Why is the procedure changing V1?
 

The problem occurs with matrices but not with lists.

 

Thanks.

 

Please Wait...