AppendTo
Usage
• AppendTo[s, elem] 将 elem 添加到 s中,并在结果中重新设置 s.
Notes
• AppendTo[s, elem] 等价于 s = Append[s, elem]. • AppendTo[s, elem] 不计算 s的值. • 可以重复使用 AppendTo 来创建一个列表. • 创建一个列表的一个可以选择并且常常更加有效的方法是使用一组形式为 s = s, elem 的赋值,然后在生成的结构中调用 Flatten.
Further Examples
This defines a list.
In[1]:=
|
Out[1]=
|
This appends the number to the end of the list.
In[2]:=
|
Out[2]=
|
The original list is changed as a side effect.
In[3]:=
|
Out[3]=
|
On the other hand, Append does not change the new version of the list.
In[4]:=
|
Out[4]=
|
In[5]:=
|
Out[5]=
|
In[6]:=
|
|