此为 Mathematica 4 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.2)

Insert

Usage

Insert[list, elem, n]list中的位置 n插入 elem 。如果n 是负的,位置从结尾计算。
Insert[expr, elem,  i, j, ...  ]expr中的位置  i, j, ...  插入elem
Insert[expr, elem,    ,  , ...  ,   ,  , ...  , ...  ]在几个位置插入elem


Notes

• 例: Insert[ a, b, c , x, 2]LongRightArrow .
Insert[ a, b, c , x,   1 ,  -1  ]LongRightArrow .
Insert[  a, b ,  c, d  , x,  2, 1 ]LongRightArrow .
list 可以有任何头,未必是List.
• 参见 Mathematica 全书: 1.8.6.
Further Examples

This inserts d into the fourth position of this list.

In[1]:=  

Out[1]=

This inserts b in the first and second positions of this list.

In[2]:=  

Out[2]=

This function builds a random permutation of Range[n] by inserting one element at a time.

In[3]:=  

In[4]:=  

Out[4]=

This function "sows" copies of the specified object between each pair of entries of expr.

In[5]:=  

In[6]:=  

Out[6]=

This variant also places copies before the first and after the last elements.

In[7]:=  

In[8]:=  

Out[8]=

In[9]:=