Skip to content

Commit

Permalink
Merge pull request #3237 from d-torrance/select-mutable-list
Browse files Browse the repository at this point in the history
Preserve mutability in "select"
  • Loading branch information
DanGrayson authored May 16, 2024
2 parents 1b27bd8 + f4d5bd9 commit a15de36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions M2/Macaulay2/d/actors4.d
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ select(e:Expr,f:Expr):Expr := (
c := select(b.v,f);
when c
is Error do c
is v:Sequence do list(b.Class,v)
is v:Sequence do list(b.Class,v,b.Mutable)
else e -- shouldn't happen
)
is n:ZZcell do (
Expand Down Expand Up @@ -221,7 +221,7 @@ select(n:Expr,e:Expr,f:Expr,g:Expr,h:Expr):Expr := (
c := select(toInt(n),b.v,f);
when c
is Error do c
is v:Sequence do list(b.Class,v)
is v:Sequence do list(b.Class,v,b.Mutable)
else e -- shouldn't happen
)
else WrongArg(1+1,"a list")
Expand Down
12 changes: 12 additions & 0 deletions M2/Macaulay2/tests/normal/mutable-lists.m2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- select w/ mutable lists
M = new MutableList from 1..10
M' = select(M, even)
assert Equation(#M', 5)
for i to 4 do assert Equation(M'#i, 2*(i + 1))
M'#0 = 5
assert Equation(M'#0, 5)
M'' = select(3, M, even)
assert Equation(#M'',3)
for i to 2 do assert Equation(M''#i, 2*(i + 1))
M''#0 = 5
assert Equation(M''#0, 5)
11 changes: 0 additions & 11 deletions bugs/dan/0-select-mutable-list

This file was deleted.

0 comments on commit a15de36

Please sign in to comment.