- See Also
-
Related Guides
- Structural Operations on Expressions
- Database-Like Operations on Datasets
- Elements of Lists
- Computation with Structured Datasets
- List Manipulation
- Constructing Lists
- Function Composition & Operator Forms
- Functional Programming
- Expressions
- Rearranging & Restructuring Lists
- Handling Arrays of Data
- Parts of Expressions
- Tech Notes
-
- See Also
-
Related Guides
- Structural Operations on Expressions
- Database-Like Operations on Datasets
- Elements of Lists
- Computation with Structured Datasets
- List Manipulation
- Constructing Lists
- Function Composition & Operator Forms
- Functional Programming
- Expressions
- Rearranging & Restructuring Lists
- Handling Arrays of Data
- Parts of Expressions
- Tech Notes
Append
Details
- In iteratively building a list, it is usually more efficient to use Sow and Reap than to use Append[list,new] at each step.
- Append works on SparseArray objects, returning ordinary lists if necessary. »
- Append can be used on Association objects. Single new elements are specified in the form key->value. New values replace older ones if their keys are the same. »
- Multiple elements to append to an association can be specified in the form {key1->value1,key2->value2, …}.
- Append[elem][expr] is equivalent to Append[expr,elem]. »
Examples
open all close allBasic Examples (3)
Append[{a, b, c, d}, x]Append[(| | |
| - | - |
| a | b |
| c | d |), {1, 2}]//MatrixFormAppend to an Association:
Append[<|1 -> a, 2 -> b|>, 3 -> d]Scope (4)
op = Append[{1, 2}];Append the list to a flat list, resulting in a nested list:
op[{a, b, c, d}]Append to a list of lists, producing a matrix:
op[{{a, b}, {c, d}, {e, f}}]%//MatrixFormsa = SparseArray[{{3, 3} -> 1}]Append a row to it, producing another sparse array:
Append[sa, {a, 0, b}]The sparse array will revert to a normal array if the array structure cannot be maintained:
Append[sa, a]Append to an expression with a general head:
Append[f[a, b, c], x + y]Append several rules to an Association:
Append[<|1 -> a, 2 -> b|>, {3 -> d, 4 -> e}]Compare with the behavior of prepending to a list of rules:
Append[{1 -> a, 2 -> b}, {3 -> d, 4 -> e}]Applications (4)
Append[{{a, b}, {c, d}}, {x, y}]//MatrixFormAppend to each row in a matrix:
Map[Append[#, x]&, {{a, b}, {c, d}}]//MatrixFormMapThread[Append, {{{a, b}, {c, d}}, {x, y}}]//MatrixFormSuccessively append to a list:
NestList[Append[#, x]&, {a}, 5]Properties & Relations (4)
Append[list,x] is equivalent to Join[list,{x}]:
Append[{a, b, c}, 1] === Join[{a, b, c}, {1}]This is true even when x is a list:
Append[{a, b, c}, {1}] === Join[{a, b, c}, {{1}}]For a general expression e, Append[e,x] is equivalent to Join[e,Head[e][x]]:
With[{e = f[a, b, c]}, Append[e, 3] === Join[e, Head[e][3]]]Append[x][e] is equivalent to Append[e,x]:
Append[x][{a, b, c}] === Append[{a, b, c}, x]When appending to an association, if a key already exists, its value will be overwritten by the appended value:
Append[<|1 -> a, 2 -> b|>, 2 -> c]Possible Issues (2)
There is no special behavior when the first and second arguments have the same head:
Append[{a, b, c}, {x, y}]It is possible to use Flatten after Append to effectively prepend several elements individually:
Flatten[%]Alternatively, use Join with the arguments reversed:
Join[{a, b, c}, {x, y}]When working on a shared list in parallel, Append is not atomic (or thread-safe):
sl = {};SetSharedVariable[sl]ParallelDo[sl = Append[sl, i ^ 2], {i, 1, 8}]slUse AppendTo in such circumstances:
sl = {};SetSharedVariable[sl]ParallelDo[AppendTo[sl, i ^ 2], {i, 1, 8}]slSee Also
Prepend Insert AppendTo PadRight Sow Join
Function Repository: AppendSequence AppendColumn AppendAt
Related Guides
-
▪
- Structural Operations on Expressions ▪
- Database-Like Operations on Datasets ▪
- Elements of Lists ▪
- Computation with Structured Datasets ▪
- List Manipulation ▪
- Constructing Lists ▪
- Function Composition & Operator Forms ▪
- Functional Programming ▪
- Expressions ▪
- Rearranging & Restructuring Lists ▪
- Handling Arrays of Data ▪
- Parts of Expressions
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2014 (10.0)
Text
Wolfram Research (1988), Append, Wolfram Language function, https://reference.wolfram.com/language/ref/Append.html (updated 2014).
CMS
Wolfram Language. 1988. "Append." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Append.html.
APA
Wolfram Language. (1988). Append. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Append.html
BibTeX
@misc{reference.wolfram_2026_append, author="Wolfram Research", title="{Append}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Append.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_append, organization={Wolfram Research}, title={Append}, year={2014}, url={https://reference.wolfram.com/language/ref/Append.html}, note=[Accessed: 12-June-2026]}