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
):
| In[45]:= |
| Out[45]= |
Use Max to get the largest element of
:
| In[46]:= |
| Out[46]= |
Set up a 4×3 matrix of random integers between 0 and 10:
| In[47]:= |
| Out[47]= |
Use Map to apply Max to each element of
at the top level:
| In[48]:= |
| Out[48]= |
You can add two lists of the same length element by element:
| In[49]:= |
| Out[49]= |
Add the scalar
to each element of a list:
| In[50]:= |
| Out[50]= |
Multiply each element in the list by the scalar
:
| In[51]:= |
| Out[51]= |
| In[43]:= |
| Out[43]= |
Prepend the element
at the beginning of the list
:
| In[44]:= |
| Out[44]= |
| In[45]:= |
| Out[45]= |
Insert the element
at position 3 of the list
:
| In[46]:= |
| Out[46]= |
Delete the element at position 3 in
:
| In[47]:= |
| Out[47]= |
Replace the element at position 3 in
with a new element
:
| In[48]:= |
| Out[48]= |
Interleave
between the entries of
:
| In[49]:= |
| Out[49]= |
