Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Overwriting...?

Hello, guys! ... First of all, I'm very new to sage and this forum, so please be generous for my question, please...

So, I've wrote in sage (between @@@@@'s):

@@@@@

p=[3,2,1];

q=p;

temporary=q[0];

q[0]=q[1];

q[1]=temporary;

@@@@@

Then, the result for p and q was

p=[2,3,1] and q=[2,3,1].

But, what I actually want is that p doesn't change; so I want to have

p=[3,2,1] and q=[2,3,1]

so that p doesn't get changed when we set 'q=p', while q is defined to be p when we set 'q=p' and then q get changed via the codes followed by 'q=p' above... In other words, is there a way to 'overwrite' q to be p, and not changing p? Thank you!!!