How to | Perform Operations on Lists

Lists are central constructs in the Wolfram Language that are used to represent collections, arrays, sets, and sequences of all kinds. Well over a thousand built-in functions throughout the Wolfram Language 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 the top level:

In[4]:=
Click for copyable input
Out[4]=
    

You can add two lists of the same length element by element:

In[1]:=
Click for copyable input
Out[1]=

Add the scalar c to each element of a list:

In[2]:=
Click for copyable input
Out[2]=

Multiply each element in the list by the scalar k:

In[3]:=
Click for copyable input
Out[3]=
    

Set up a list of 5 integers:

In[1]:=
Click for copyable input
Out[1]=

Prepend the element x at the beginning of the list v:

In[2]:=
Click for copyable input
Out[2]=

Append x at the end of v:

In[3]:=
Click for copyable input
Out[3]=

Insert the element x at position 3 of the list v:

In[4]:=
Click for copyable input
Out[4]=

Delete the element at position 3 in v:

In[5]:=
Click for copyable input
Out[5]=

Replace the element at position 3 in v with a new element x:

In[6]:=
Click for copyable input
Out[6]=

Interleave x between the entries of v:

In[7]:=
Click for copyable input
Out[7]=

Tutorials

See Also

List  Prepend  Append  Map  Apply  Insert  Delete  ReplacePart  Riffle