Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Expressions > Parts of Expressions >

Insert

Insert[list, elem, n]
inserts elem at position n in list. If n is negative, the position is counted from the end.
Insert[expr, elem, {i, j, ...}]
inserts elem at position {i, j, ...} in expr.
Insert[expr, elem, {{i1, j1, ...}, {i2, j2, ...}, ...}]
inserts elem at several positions.
  • list can have any head, not necessarily List.
  • Insert works on SparseArray objects by effectively inserting into the corresponding ordinary lists.
Insert x to be at position 3:
Insert x to be at position 2 from the end:
Insert x at several positions:
Insert into a 2D array:
Insert x to be at position 3:
In[1]:=
Click for copyable input
Out[1]=
 
Insert x to be at position 2 from the end:
In[1]:=
Click for copyable input
Out[1]=
 
Insert x at several positions:
In[1]:=
Click for copyable input
Out[1]=
 
Insert into a 2D array:
In[1]:=
Click for copyable input
Out[1]=
Insert into an expression with any head:
Insert at any position in any expression:
Insert into a held expression:
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team