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 allclose all

Basic Examples  (3)

In[1]:=
Click for copyable input
Out[1]=

Append to an Association:

In[1]:=
Click for copyable input
Out[1]=

Append several rules to an Association:

In[1]:=
Click for copyable input
Out[1]=

Generalizations & Extensions  (1)

Applications  (4)

Possible Issues  (1)

See Also

Prepend  Insert  AppendTo  PadRight  Sow  Join

Tutorials

Introduced in 1988
(1.0)
| Updated in 2014
(10.0)