Skip to content

Commit 8fc0a87

Browse files
committed
Allow all types of list on the RHS of parallel assignment
1 parent 6c8dee4 commit 8fc0a87

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

M2/Macaulay2/d/evaluate.d

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,8 +1206,16 @@ parallelAssignmentFun(x:parallelAssignmentCode):Expr := (
12061206
when value is a:Sequence do (
12071207
-- unless y is a sequence of length 1, then it behaves like x = y#0
12081208
if length(a) == 1 then nothing
1209-
else value = ParallelAssignmentError(1))
1209+
else return ParallelAssignmentError(1))
1210+
is a:List do (
1211+
if length(a.v) == 1 then nothing
1212+
else return ParallelAssignmentError(1))
12101213
else value = seq(value));
1214+
klass := sequenceClass;
1215+
when value is a:List do (
1216+
value = Expr(a.v);
1217+
klass = a.Class)
1218+
else nothing;
12111219
when value
12121220
is values:Sequence do (
12131221
if nlhs == length(values) then (
@@ -1280,7 +1288,10 @@ parallelAssignmentFun(x:parallelAssignmentCode):Expr := (
12801288
else r));
12811289
when e
12821290
is Error do e
1283-
else if nlhs == 1 then result.0 else Expr(result))
1291+
else if nlhs == 1 then result.0
1292+
else (
1293+
if klass == sequenceClass then Expr(result)
1294+
else list(klass, result)))
12841295
else ParallelAssignmentError(nlhs))
12851296
else ParallelAssignmentError(nlhs));
12861297

M2/Macaulay2/tests/normal/parallel.m2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ assert Equation(() = (), ())
112112
assert Equation(() := (), ())
113113
assert Equation(() += (), ())
114114

115+
-- other types of list on RHS
116+
assert Equation((x, y, z) = {1, 2, 3}, {1, 2, 3})
117+
assert Equation((x, y, z), (1, 2, 3))
118+
assert Equation((x, y, z) = [4, 5, 6], [4, 5, 6])
119+
assert Equation((x, y, z), (4, 5, 6))
120+
assert Equation((x, y, z) = <|7, 8, 9|>, <|7, 8, 9|>)
121+
assert Equation((x, y, z), (7, 8, 9))
122+
assert Equation((x) = {10}, 10)
123+
assert Equation(x, 10)
124+
115125
end
116126
-- Local Variables:
117127
-- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/test parallel.out"

0 commit comments

Comments
 (0)