Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Assignments  /
AddTo

  • x += dx adds dx to x and returns the new value of x.
  • AddTo has the attribute HoldFirst.
  • x += dx is equivalent to x = x + dx.
  • See the Mathematica book: Section 2.4.4.
  • See also: Increment, PreIncrement, Set, PrependTo.

    Further Examples

    This initializes the variable i to the value 7, adds to it, checks its value, and clears it at the end.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]=

    In[3]:=

    Out[3]=

    In[4]:=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.