This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# Partition

 Partitionpartitions list into non-overlapping sublists of length n. Partitiongenerates sublists with offset d. Partitionpartitions a nested list into blocks of size .... Partitionuses offset at level i in list. Partitionspecifies that the first element of list should appear at position in the first sublist, and the last element of list should appear at or after position in the last sublist. If additional elements are needed, Partition fills them in by treating list as cyclic. Partitionpads if necessary by repeating the element x. Partitionpads if necessary by cyclically repeating the elements . Partitionuses no padding, and so can yield sublists of different lengths. Partitionspecifies alignments and padding in a nested list.
• All the sublists generated by Partition are of length n. Some elements at the end of list may therefore not appear in any sublist.
• All elements of list appear in the sublists generated by Partition.
• If d is greater than n in Partition, then elements in the middle of list are skipped. »
• Partition effectively allows sublists that have overhangs that extend past the beginning or end of list.
• Common settings for are:
 {1,-1} allow no overhangs {1,1} allow maximal overhang at the end {-1,-1} allow maximal overhang at the beginning {-1,1} allow maximal overhangs at both beginning and end
• Partition effectively lays down repeated copies of padlist, then superimposes one copy of list on them, and partitions the result. »
• Common settings for padlist are:
 x pad with repetitions of a single element {x1,x2,...} pad with cyclic repetitions of a sequence of elements list pad by treating list as cyclic (default) {} do no padding, potentially leaving sublists of different lengths
• Partition effectively replaces blocks of elements at level r in list by depth-r nested lists of neighboring elements. »
• If no offsets are specified, the neighborhoods are adjacent and non-overlapping.
• Partition specifies that element of list should appear at position in the block of the result, while element of list should appear at or after position in the block of the result.
• is taken to be equivalent to .
• is taken to be equivalent to .
• Partition effectively makes a depth-r array of copies of padlist, then superimposes list on them, and partitions the result.
• If list has dimensions then Partition will have dimensions where is given by Floor.
• The object list need not have head List. »
Partition into sublists of length 2:
Partition into sublists of length 3 with offset 1:
Partition a two-dimensional array into 2×2 blocks with offset 1:
Partition into sublists of length 2:
 Out[1]=

Partition into sublists of length 3 with offset 1:
 Out[1]=

Partition a two-dimensional array into 2×2 blocks with offset 1:
 Out[1]=
 Scope   (16)
Incomplete sublists at the end are by default dropped:
Treat the list as cyclic:
Use no padding, so later sublists can be shorter:
Make the input start at position 2 in the first sublist, and end at position 1 in the last sublist:
Pad by laying down repeating copies of :
Partition into 2×2 blocks:
Partition into 2×2 blocks with offset 1, padding at the ends of rows and columns with :
Partition into 2×2 blocks with offset 1, taking the array to be cyclic in both dimensions:
Insert padding at the beginnings of columns, and the beginnings and ends of rows:
Pad the beginnings and ends of columns, and the ends of rows:
Skip elements by using an offset larger than the block size:
Padding can be longer than the block size:
The head need not be List:
Partition works with SparseArray objects:
 Applications   (5)
Partition to lay out a list in 2D:
Find pairs of successive elements in a list:
Find successive ratios in a list:
Implement an elementary cellular automaton:
Partition a flat list of elements into a multidimensional array with specified dimensions:
Create a multidimensional array of successive integers:
Restructure a matrix:
Flatten is essentially the inverse of Partition:
ListCorrelate effectively combines ker with a partitioned list:
Partition the list into segments the length of ker with offset 1:
Use Dot to combine the kernel with each segment:
ListConvolve is similar except the kernel is reversed: