appends elem to the value of x, and resets x to the result.



open allclose all

Basic Examples  (1)

Assign to l a list:

Include a new value at the end of the list:

The value assigned to l has changed:

Scope  (5)

Use an arbitrary head:

Append to an Association:

Assigns to s a sparse matrix:

Add a row to the matrix:

Appending an element with inconsistent dimensions requires converting to ordinary lists:

The first argument to AppendTo need not be a symbol:

Append to a shared list in parallel:

Applications  (1)

Assign m to be a 2×2 matrix:

Append a row to m:

Append a column to m:

m is now a 3×3 matrix:

Possible Issues  (5)

The first argument must have a value:

The first argument must be assigned to something which can be appended to:

Something for which AtomQ is True cannot generally be appended to:

Using AppendTo on a column of a matrix replaces column values:

Append to a matrix column:

Reset the column values with the new value:

Using AppendTo to accumulate values in large loops can be slow:

There are many alternatives, such as using Reap and Sow:

When working on a shared list in parallel, AppendTo is atomic:

The seemingly equivalent expression using Append is not atomic:

Wolfram Research (1988), AppendTo, Wolfram Language function, (updated 2014).


Wolfram Research (1988), AppendTo, Wolfram Language function, (updated 2014).


@misc{reference.wolfram_2021_appendto, author="Wolfram Research", title="{AppendTo}", year="2014", howpublished="\url{}", note=[Accessed: 17-June-2021 ]}


@online{reference.wolfram_2021_appendto, organization={Wolfram Research}, title={AppendTo}, year={2014}, url={}, note=[Accessed: 17-June-2021 ]}


Wolfram Language. 1988. "AppendTo." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014.


Wolfram Language. (1988). AppendTo. Wolfram Language & System Documentation Center. Retrieved from