Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  Built-in Functions /  Lists and Matrices /  Structure Manipulation /

Partition

FilledSmallSquare Partition[list, n] divides list into non-overlapping sublists of length n.
FilledSmallSquare Partition[list, n, d] generates sublists with offset d.
FilledSmallSquare Partition[list, , , ... ] divides a nested list into blocks of size .
FilledSmallSquare Partition[list, , , ... , , , ... ] uses offset at level i in list.
FilledSmallSquare Partition[list, n, d, , ] 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.
FilledSmallSquare Partition[list, n, d, , , x] pads if necessary by repeating the element x.
FilledSmallSquare Partition[list, n, d, , , , , ... ] pads if necessary by cyclically repeating the elements .
FilledSmallSquare Partition[list, n, d, , , ] uses no padding, and so can yield sublists of different lengths.
FilledSmallSquare Partition[list, nlist, dlist, , , padlist] specifies alignments and padding in a nested list.

FilledSmallSquare Example: Partition[a,b,c,d,e,f, 2]LongRightArrow.
FilledSmallSquare 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.
FilledSmallSquare The element e in Partition[a,b,c,d,e, 2]LongRightArrow is dropped.
FilledSmallSquare Partition[a,b,c,d,e, 3, 1]LongRightArrow generates sublists with offset 1.
FilledSmallSquare All elements of list appear in the sublists generated by Partition[list, n, 1].
FilledSmallSquare If d is greater than n in Partition[list, n, d], then elements in the middle of list are skipped.
FilledSmallSquare Partition[list, 1, d] picks out elements in the same way as Take[list, 1, -1, d].
FilledSmallSquare Partition[list, n, d, , ] effectively allows sublists that have overhangs that extend past the beginning or end of list.
FilledSmallSquare Partition[list, n, d, k] is equivalent to Partition[list, n, d, k, k].

FilledSmallSquare Common settings for , are:

FilledSmallSquare Example: Partition[a,b,c,d,2,1,-1,1]LongRightArrow.
FilledSmallSquare Partition[list, n, d, , , padlist] effectively lays down repeated copies of padlist, then superimposes one copy of list on them, and partitions the result.
FilledSmallSquare Common settings for padlist are:

FilledSmallSquare Example: Partition[a,b,c,d,2,1,-1,1,x,y]LongRightArrow.
FilledSmallSquare Partition[a,b,c,d,2,1,-1,1,]LongRightArrow.
FilledSmallSquare If list has length s, then Partition[list, n, d] yields Max[0, Floor[(s + d - n)/d]] sublists.
FilledSmallSquare Partition[list, , , ... , ] effectively replaces blocks of elements at level r in list by depth r nested lists of neighboring elements.
FilledSmallSquare If no offsets are specified, the neighborhoods are adjacent and non-overlapping.
FilledSmallSquare Partition[list, , , ... , d] uses offset d at every level.
FilledSmallSquare Partition[list, nlist, dlist, , , ... , , , ... ] specifies that element 1,1,... of list should appear at position , , ... in the 1,1,... block of the result, while element -1,-1,... of list should appear at or after position , , ... in the -1,-1,... block of the result.
FilledSmallSquare , is taken to be equivalent to , , ... , , , ... .
FilledSmallSquare , , ... is taken to be equivalent to , , ... , , , ... .
FilledSmallSquare Partition[list, , , ... , , klist, padlist] effectively makes a depth r array of copies of padlist, then superimposes list on them, and partitions the result.
FilledSmallSquare If list has dimensions , , ... , then Partition[list, , , ... , ] will have dimensions , , ... , , , , ... , where is given by Floor[/].
FilledSmallSquare The object list need not have head List.
FilledSmallSquare Partition[f[a,b,c,d], 2]LongRightArrow.
FilledSmallSquare See The Mathematica Book on the web: Section 1.8.10.
FilledSmallSquare See also: Flatten, RotateLeft, Split, Take.