partitions list into nonoverlapping sublists of length n.

generates sublists with offset d.

partitions a nested list into blocks of size ××.

uses offset at level i in list.

specifies 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.

pads if necessary by repeating the element x.

pads if necessary by cyclically repeating the elements .

uses no padding, and so can yield sublists of different lengths.

specifies alignments and padding in a nested list.


  • All the sublists generated by Partition[list,n,d] are of length n. Some elements at the end of list may therefore not appear in any sublist.
  • Partition[list,UpTo[n]] partitions into sublists of length up to n, allowing the final sublist to be shorter.
  • All elements of list appear in the sublists generated by Partition[list,n,1].
  • If d is greater than n in Partition[list,n,d], then elements in the middle of list are skipped. »
  • Sublist lengths can always be specified as UpTo[n], in which case shorter sublists can be returned if fewer than n elements are available.
  • Partition[list,n,d,{kL,kR}] effectively allows sublists that have overhangs that extend past the beginning or end of list.
  • Partition[list,n,d,k] is equivalent to Partition[list,n,d,{k,k}].
  • 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[list,n,d,{kL,kR},padlist] effectively lays down repeated copies of padlist, then superimposes one copy of list on them and partitions the result. »
  • Common settings for padlist are:
  • xpad with repetitions of a single element
    {x1,x2,}pad with cyclic repetitions of a sequence of elements
    listpad by treating list as cyclic (default)
    {}no padding, potentially leaving sublists of different lengths
  • If list has length s, then Partition[list,n,d] yields Max[0,Floor[(s+d-n)/d]] sublists.
  • Partition[list,{n1,n2,,nr}] 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 nonoverlapping.
  • Partition[list,{n1,n2,},d] uses offset d at every level.
  • Partition[list,nlist,dlist,{{kL 1,kL 2,},{kR 1,kR 2,}}] 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[list,{n1,n2,,nr},klist,padlist] 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[list,{n1,n2,,nr}] will have dimensions , where is given by Floor[si/ni].
  • The object list need not have head List. »
  • Partition can be used on SparseArray objects.
Introduced in 1988
| Updated in 2015
Translate this page: