[GAP Forum] Help please

Robert Bailey robert.bailey at ryerson.ca
Wed Aug 14 15:51:42 BST 2013


Dear Abdulsatar,

When you assign Y and Y1 to be equal to L, GAP will (internally) treat all 
three as the same object.  Thus when you change Y1, it will also change L 
and Y in the same way.

To create duplicates of L, you need the "StructuralCopy" command:

Y:=StructuralCopy(L);
Y1:=StructuralCopy(L);

which will create Y and Y1 as separate objects identical to L.

Regards,
Robert Bailey.

-----Original Message----- 
From: Abdulsatar Al-Juburie
Sent: Monday, August 12, 2013 3:50 PM
To: 'forum at mail.gap-system.org'
Subject: [GAP Forum] Help please

Dear All,


In the following small code when  I try to print  Y , I found that  Y  is 
changed , but I did change just on Y1.  Is there any way to print  Y

Without any change.



f:=function(L)
local i,j,Y,Y1;

Y:=L;
Y1:=L;

Y1[1][1]:=90;
Y1[2][1]:=90;

Print(" ","\n");
Print("\ Y =",Y);
Print(" ","\n");

Print("\ Y1=",Y1);
Print(" ","\n");
end;

The input to the function is:

f([ [ 0, 21, 31, 41 ], [ 1, 0, 21, 31 ], [ 0, 0, 0, 21 ], [ 0, 0, 0, 0 ] ]);


Result of print is:

Y =[ [ 90, 21, 31, 41 ], [ 90, 0, 21, 31 ], [ 0, 0, 0, 21 ], [ 0, 0, 0, 
0 ] ]

Y1=[ [ 90, 21, 31, 41 ], [ 90, 0, 21, 31 ], [ 0, 0, 0, 21 ], [ 0, 0, 0, 
0 ] ]


Any idea and/or help are more than appreciated


Regards,


Abdulsatar


_______________________________________________
Forum mailing list
Forum at mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum 




More information about the Forum mailing list