此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)
Mathematica HowTo
How to | Perform Operations on Lists
Lists are central constructs in Mathematica that are used to represent collections, arrays, sets, and sequences of all kinds. Well over a thousand built-in functions throughout Mathematica operate directly on lists, making them a powerful vehicle for interoperability.
Set up a list of 5 random integers between 0 and 10 (stored as v):
In[1]:=
Click for copyable input
Out[1]=
Use Max to get the largest element of v:
In[2]:=
Click for copyable input
Out[2]=
Set up a 4×3 matrix of random integers between 0 and 10:
In[3]:=
Click for copyable input
Out[3]=
Use Map to apply Max to each element of m at top level:
In[4]:=
Click for copyable input
Out[4]=
    
You can add two lists of the same length element-by-element:
In[5]:=
Click for copyable input
Out[5]=
Add the scalar c to each element of a list:
In[6]:=
Click for copyable input
Out[6]=
Multiply each element in the list by the scalar k:
In[7]:=
Click for copyable input
Out[7]=
    
Set up a list of 5 integers:
In[8]:=
Click for copyable input
Out[8]=
Prepend the element x at the beginning of the list v:
In[9]:=
Click for copyable input
Out[9]=
Append x at the end of v:
In[10]:=
Click for copyable input
Out[10]=
Insert the element x at position 3 of the list v:
In[11]:=
Click for copyable input
Out[11]=
Delete the element at position 3 in v:
In[12]:=
Click for copyable input
Out[12]=
Replace the element at position 3 in v with a new element x:
In[13]:=
Click for copyable input
Out[13]=
Interleave x between the entries of v:
In[14]:=
Click for copyable input
Out[14]=