GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • WOLFRAM
  • Products
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App
  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs
  • Wolfram AI Ecosystem

This view

  • Original page
  • New address

GeezerVison is showing reference.wolfram.com — Append: Add an item to the end of a list or association—Wolfram Documentation

Append[expr,elem]

gives expr with elem appended.

Append[elem]

represents an operator form of Append that can be applied to an expression.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
Possible Issues  
See Also
Tech Notes
Related Guides
Related Links
History
Cite this Page

Append

Append[expr,elem]

gives expr with elem appended.

Append[elem]

represents an operator form of Append that can be applied to an expression.

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 all

Basic Examples  (3)

Append an element to a list:

Wolfram Language code: Append[{a, b, c, d}, x]

Append a row to a matrix:

Wolfram Language code: Append[(⁠| | | | - | - | | a | b | | c | d |⁠), {1, 2}]//MatrixForm

Append to an Association:

Wolfram Language code: Append[<|1 -> a, 2 -> b|>, 3 -> d]

Scope  (4)

Define an append operator:

Wolfram Language code: op = Append[{1, 2}];

Append the list to a flat list, resulting in a nested list:

Wolfram Language code: op[{a, b, c, d}]

Append to a list of lists, producing a matrix:

Wolfram Language code: op[{{a, b}, {c, d}, {e, f}}]

Format the matrix:

Wolfram Language code: %//MatrixForm

Create a 3×3 sparse array:

Wolfram Language code: sa = SparseArray[{{3, 3} -> 1}]

Append a row to it, producing another sparse array:

Wolfram Language code: Append[sa, {a, 0, b}]

The sparse array will revert to a normal array if the array structure cannot be maintained:

Wolfram Language code: Append[sa, a]

Append to an expression with a general head:

Wolfram Language code: Append[f[a, b, c], x + y]

Append several rules to an Association:

Wolfram Language code: Append[<|1 -> a, 2 -> b|>, {3 -> d, 4 -> e}]

Compare with the behavior of prepending to a list of rules:

Wolfram Language code: Append[{1 -> a, 2 -> b}, {3 -> d, 4 -> e}]

Applications  (4)

Append a row to a matrix:

Wolfram Language code: Append[{{a, b}, {c, d}}, {x, y}]//MatrixForm

Append to each row in a matrix:

Wolfram Language code: Map[Append[#, x]&, {{a, b}, {c, d}}]//MatrixForm

Append a vector to a matrix:

Wolfram Language code: MapThread[Append, {{{a, b}, {c, d}}, {x, y}}]//MatrixForm

Successively append to a list:

Wolfram Language code: NestList[Append[#, x]&, {a}, 5]

Properties & Relations  (4)

Append[list,x] is equivalent to Join[list,{x}]:

Wolfram Language code: Append[{a, b, c}, 1] === Join[{a, b, c}, {1}]

This is true even when x is a list:

Wolfram Language code: 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]]:

Wolfram Language code: With[{e = f[a, b, c]}, Append[e, 3] === Join[e, Head[e][3]]]

Append[x][e] is equivalent to Append[e,x]:

Wolfram Language code: 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:

Wolfram Language code: 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:

Wolfram Language code: Append[{a, b, c}, {x, y}]

It is possible to use Flatten after Append to effectively prepend several elements individually:

Wolfram Language code: Flatten[%]

Alternatively, use Join with the arguments reversed:

Wolfram Language code: Join[{a, b, c}, {x, y}]

When working on a shared list in parallel, Append is not atomic (or thread-safe):

Wolfram Language code: sl = {};SetSharedVariable[sl]
Wolfram Language code: ParallelDo[sl = Append[sl, i ^ 2], {i, 1, 8}]
Wolfram Language code: sl

Use AppendTo in such circumstances:

Wolfram Language code: sl = {};SetSharedVariable[sl]
Wolfram Language code: ParallelDo[AppendTo[sl, i ^ 2], {i, 1, 8}]
Wolfram Language code: sl

See Also

Prepend  Insert  AppendTo  PadRight  Sow  Join

Function Repository: AppendSequence  AppendColumn  AppendAt

Tech Notes

    ▪
  • Adding, Removing, and Modifying List Elements
  • ▪
  • Manipulating Lists by Their Indices

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

Related Links

  • An Elementary Introduction to the Wolfram Language : Assigning Names to Things

History

Introduced 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).

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-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]}

Top
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.