Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » variables » augmented assignment
next | previous | forward | backward | up | index | toc

augmented assignment

Most binary operators have an associated augmented assignment operator that modifies the given object using the corresponding binary operator. Essentially, x OP= y is equivalent to x = x OP y.

i1 : x = 2

o1 = 2
i2 : x += 3

o2 = 5
i3 : x -= 4

o3 = 1
i4 : x *= 5

o4 = 5
i5 : x /= 6

     5
o5 = -
     6

o5 : QQ

The following augmented assignment operators are supported.

i6 : importFrom(Core, "augmentedAssignmentOperators");
i7 : augmentedAssignmentOperators

o7 = (<<=, >>=, ||=, <==>=, |-=, ??=, ==>=, ===>=, |=, ^^=, &=, ..=, ..<=,
     ------------------------------------------------------------------------
     -=, +=, ++=, **=, *=, \\=, /=, \=, %=, //=, @=, @@=, @@?=, ~=, |_=, ^=,
     ------------------------------------------------------------------------
     _=, ^**=, ·=, ⊠=, ⧢=)

o7 : Sequence

Multiple augmented assignment is also supported.

i8 : (x,y) = (3, 4)

o8 = (3, 4)

o8 : Sequence
i9 : (x,y) += (5, 6)

o9 = (8, 10)

o9 : Sequence
i10 : (x,y)

o10 = (8, 10)

o10 : Sequence

See also


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/Macaulay2Doc/operators/augmented_assignment.m2:30:0.