Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Defining Variables and Functions > Assignments >

AddTo (+=)

x+=dx
adds dx to x and returns the new value of x.
  • x+=dx is equivalent to x=x+dx.
Add to a numerical value:
Add to a symbolic value:
Add to all values in a list:
Find the first prime above one million:
AddTo is a short form of this assignment:
PreIncrement is a special case of AddTo:
SubtractFrom is closely related:
A related operation for lists is AppendTo:
A variable to be incremented must have an initial value:
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team