How to | Combine and Rearrange Lists

The Wolfram System provides a complete data manipulation language with vast flexibility in rearranging lists with any number of elements in any kind of structure.

Set up a list of six integers with some duplicates (stored as v):

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

Sort the elements of the list v:

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

Use Union to sort v and remove any duplicates:

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

Note that unless you redefine v, it retains its original value:

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

Redefine v:

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

Reverse the order of v:

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

Rotate the elements of v two places to the left:

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

Rotate the elements of v two places to the right:

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

Pad v on the left with x to get a list of length 10:

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

Partition the list v into sublists of length 2:

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

Partition the list v into sublists of length 2 with offset 1:

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

Split a list into runs of identical elements:

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

Flatten deletes inner braces in nested lists:

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

Join the elements of a set of lists:

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