[GAP Forum] immutable --> mutable lists
Alexander Konovalov
alexk at mcs.st-and.ac.uk
Sun Jun 17 11:58:52 BST 2007
Dear Dmytro,
1) In your example, it is fine to use
List(l, x->List(x));
Maybe I would use only the notation
List(l, ShallowCopy )
to make more it more visible what's going on.
2) Besides this, if l is a matrix, you may use MutableCopyMat,
that will use exactly List(l, ShallowCopy ) to produce the output:
gap> l := [ [1,2], [3,4] ];
[ [ 1, 2 ], [ 3, 4 ] ]
gap> MakeImmutable(l);
gap> IsMutable(l[1]);
false
gap> IsMutable(l);
false
gap> m:=MutableCopyMat(l);
[ [ 1, 2 ], [ 3, 4 ] ]
gap> IsMutable(m);
true
gap> IsMutable(m[1]);
true
There are no other functions in GAP for more general cases.
Best wishes,
Alexander
On 16 Jun 2007, at 02:03, Dmytro Savchuk wrote:
> Dear Forum,
>
> I have one simple question. Suppose we have an immutable list whose
> entries are immutable lists (e.g. l := [ [1,2], [3,4] ] ). What is the
> easiest way to make a mutable copy of this structure (so that the
> entries become also mutable). The one I came up with is obvious
>
> List(l, x->List(x));
>
> It works here (where I need it), but what if the dimension of the list
> is bigger than 2? Maybe there is something more general? Or it is
> necessary to use some recursion?
>
> Thank you!
> Dmytro Savchuk
More information about the Forum
mailing list