Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  The Teacher's Book /  Interlude 1: Lists /

12.5 Adding, Removing and Modifying List Elements

Functions for adding and deleting elements in lists.

This gives a list with x prepended.

In[1]:= Prepend[{a, b, c}, x]

Out[1]=

This adds x at the end.

In[2]:= Append[{a, b, c}, x]

Out[2]=

This inserts x so that it becomes element number 2.

In[3]:= Insert[{a, b, c}, x, 2]

Out[3]=

Negative numbers count from the end of the list.

In[4]:= Insert[{a, b, c}, x, -2]

Out[4]=

Delete removes an element from the list.

In[5]:= Delete[{a, b, c, d}, 3]

Out[5]=