Legacy Documentation

Mathematica CalcCenter 2 (2002)

This is documentation for an obsolete product.
Current products and services

Documentation / CalculationCenter / Functions / Lists & Matrices / List Manipulation /

Partition

FilledSmallSquare Partition[list, n] partitions list into nonoverlapping sublists of length n.

FilledSmallSquare Partition[list, n, d] generates sublists with offset d.

FilledSmallSquare Partition[list, {, , ... }] partitions 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:

{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

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:

x            pad with repetitions of a single element

{, , ... }        pad with cyclic repetitions of a sequence of elements

list            pad by treating the list as cyclic (default)

{}            do no padding, potentially leaving sublists of different length

FilledSmallSquare Examples: Partition[{a, b, c, d}, 2, 1, {-1, 1}, {x, y}] LongRightArrow .

FilledSmallSquare Partition[{a, b, c, d}, 2, 1, {-1, 1}, {}] LongRightArrow .

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

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 See also: Flatten, Take.

Examples

Using InstantCalculators

Here is the InstantCalculator for the Partition function. Enter the parameters for your calculation and click Calculate to see the result.

In[1]:=

Out[1]=

Entering Commands Directly

You can paste a template for this command via the Text Input button on the Partition Function Controller.

This groups the elements of the original list in pairs; the seventh is thrown away.

In[2]:=

Out[2]=

This makes triples of elements, with each successive triple offset by just one element.

In[3]:=

Out[3]=



ja