GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing reference.wolfram.com — Append: Add an item to the end of a list or association—Wolfram Documentation AppendDetails
Examplesopen all close allBasic Examples (3)Append an element to a list: Append[{a, b, c, d}, x]Append a row to a matrix: Append[(| | |
| - | - |
| a | b |
| c | d |), {1, 2}]//MatrixFormAppend to an Association: Append[<|1 -> a, 2 -> b|>, 3 -> d]Scope (4)Define an append operator: 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}}]Format the matrix: %//MatrixFormCreate a 3×3 sparse array: sa = 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 row to a matrix: Append[{{a, b}, {c, d}}, {x, y}]//MatrixFormAppend to each row in a matrix: Map[Append[#, x]&, {{a, b}, {c, d}}]//MatrixFormAppend a vector to a matrix: MapThread[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 AlsoPrepend Insert AppendTo PadRight Sow Join Function Repository: AppendSequence AppendColumn AppendAt Related Guides
HistoryIntroduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2014 (10.0)
Wolfram Research (1988), Append, Wolfram Language function, https://reference.wolfram.com/language/ref/Append.html (updated 2014).
TextWolfram Research (1988), Append, Wolfram Language function, https://reference.wolfram.com/language/ref/Append.html (updated 2014). CMSWolfram Language. 1988. "Append." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Append.html. APAWolfram 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-November-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-November-2026]} |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |