MATHEMATICA HOW TO

# How to | Combine and Rearrange Lists

Mathematica 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 ):

 Out[1]=

Sort the elements of the list :

 Out[2]=

Use Union to sort and remove any duplicates:

 Out[3]=

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

 Out[4]=

Redefine :

 Out[5]=
 Out[6]=

Reverse the order of :

 Out[7]=

Rotate the elements of two places to the left:

 Out[8]=

Rotate the elements of two places to the right:

 Out[9]=

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

 Out[10]=

Partition the list into sublists of length 2:

 Out[11]=

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

 Out[12]=

Split a list into runs of identical elements:

 Out[13]=

Flatten deletes inner braces in nested lists:

 Out[14]=

Join the elements of a set of lists:

 Out[15]=

## See AlsoSee Also

New to Mathematica? Find your learning path »
Have a question? Ask support »