Open mahrud opened 4 years ago
Yes:
Macaulay2, version 1.16
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems, LLLBases,
MinimalPrimes, PrimaryDecomposition, ReesAlgebra, TangentCone, Truncations
i1 : A = new MutableList
o1 = MutableList{}
o1 : MutableList
i2 : A#0=x
o2 = x
o2 : Symbol
i3 : A#1=y
o3 = y
o3 : Symbol
i4 : #A
o4 = 2
i5 : A##A=z -- here's how to append
o5 = z
o5 : Symbol
i6 : peek A
o6 = MutableList{x, y, z}
PS: yes, when modifying a mutable hash table, no copies are made.
Ah, thank you. How bad would it be to modify append
and prepend
to do this for mutable lists?
Reopening to remember the bug with delete
on a MutableList.
Mutability of the mutable list is set to false.
i1 : L = new MutableList from {"A", "B"}
o1 = MutableList{...2...}
o1 : MutableList
i2 : mutable L
o2 = true
i3 : delete("A", L)
o3 = MutableList{...1...}
o3 : MutableList
i4 : mutable oo
o4 = false
i5 : delete(L, 1)
o5 = {0}
o5 : List
Is there a way to manipulate mutable lists without making a new copy? For instance:
For comparison, mutable hash tables can be manipulated in place:
I assume no copies are being made here, or at least I hope so!