AddTo

x+=dx

adds dx to x and returns the new value of x.

Details

  • x+=dx is equivalent to x=x+dx.
  • AddTo has the attribute HoldFirst.
  • In AddTo[x,f], x can be a symbol or other expression with an existing value. »

Examples

open allclose all

Basic Examples  (1)

Scope  (4)

Add to a numerical value:

Add to a symbolic value:

Add to all values in a list:

The first argument to AddTo need not be a symbol:

Applications  (1)

Find the first prime above one million:

Properties & Relations  (4)

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:

Possible Issues  (1)

A variable to be incremented must have an initial value:

Wolfram Research (1988), AddTo, Wolfram Language function, https://reference.wolfram.com/language/ref/AddTo.html.

Text

Wolfram Research (1988), AddTo, Wolfram Language function, https://reference.wolfram.com/language/ref/AddTo.html.

CMS

Wolfram Language. 1988. "AddTo." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AddTo.html.

APA

Wolfram Language. (1988). AddTo. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AddTo.html

BibTeX

@misc{reference.wolfram_2024_addto, author="Wolfram Research", title="{AddTo}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/AddTo.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_addto, organization={Wolfram Research}, title={AddTo}, year={1988}, url={https://reference.wolfram.com/language/ref/AddTo.html}, note=[Accessed: 22-November-2024 ]}