Take
Usage
• Take[list, n] 给出list中的前n个元素。
• Take[list, -n] 给出list中的最后n个元素。
• Take[list, m, n ] 给出 list中的从 m到 n的元素。
• Take[list, m, n, s ] 给出 list中步长为 s的从 m到 n的元素。
• Take[list, , , ... ] 给出一个嵌套列表,其中由指定的元素从 list的层 i中取出。
Notes
• Take 可以用于一个有任何头,未必在List中的对象。 • Take[list, , ] 有效的从 list中提取一个子矩阵。 • 参见 Mathematica 全书 : 节 1.8.4.
Further Examples
This takes the first three elements from the list.
In[1]:=
|
Out[1]=
|
This takes the last two elements from the list.
In[2]:=
|
Out[2]=
|
|