New to sage and python, so I'm not sure which I'm abusing. I'm trying to define the following function which acts on the input list A, but every time I input the function affects the global value of A. How can I make it behave locally?
def listxgcd( A ):
g,s,t=xgcd(A.pop(0),A.pop(0))
coeffs=[s,t]
while a!=[]:
g,s,t=xgcd(g,A.pop(0))
coeffs=[s*i for i in coeffs]
coeffs=coeffs+[t]
return coeffs
I've tried setting B=A
and substituting B everywhere but this doesn't work either which I don't understand. Do I need to declare some sort of sage-y variable thing?
def listxgcd( a ):
B=a
g,s,t=xgcd(B.pop(0),B.pop(0))
coeffs=[s,t]
while B!=[]:
g,s,t=xgcd(g,B.pop(0))
coeffs=[s*i for i in coeffs]
coeffs=coeffs+[t]
return coeffs
Much thanks!