Skip to content

Commit 8f9c390

Browse files
committed
Preserve class when subsetting a list
1 parent 89952b8 commit 8f9c390

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

M2/Macaulay2/m2/lists.m2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ List / RingElement := List / Number := List => (v,b) -> apply(v,x->x / b)
3333
List // RingElement := List // Number := List => (v,b) -> apply(v,x->x // b)
3434
List % RingElement := List % Number := List => (v,b) -> apply(v,x->x % b)
3535

36-
VisibleList _ List := VisibleList => (x,y) -> apply(splice y, i -> x#i)
36+
VisibleList _ List := VisibleList => (x,y) -> (
37+
L := class x;
38+
new L from apply(splice y, i -> x#i))
3739

3840
Sequence .. Sequence := Sequence => (v,w) -> (
3941
n := #v;

M2/Macaulay2/packages/Macaulay2Doc/operators/underscore.m2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ document {
4747
SeeAlso => {(symbol #, BasicList, ZZ)},
4848
}
4949
document {
50-
Key => (symbol _, VisibleList, List),
50+
Key => (symbol _, VisibleList, VisibleList),
5151
Headline => "get some entries of a list",
5252
Usage => "w_{i,j,...}",
5353
Inputs => {

M2/Macaulay2/tests/normal/lists.m2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ assert (net i == "<|x, y, z|>"^0)
1818
assert (toList i === {x,y,z})
1919
assert (class i === AngleBarList)
2020
assert (delete(y, i) == <| x, z |>)
21+
assert (i_{0,2} == <| x, z |>)
2122

2223
assert isTable table(0, 0, identity)

0 commit comments

Comments
 (0)