Partition
The collection split into consecutive, non-overlapping chunks of length n.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
Partition of a setMathWorldSetPartitionWikidataQ381060Britannicatopic/partition-of-a-setWolfram LanguagePartition✓Partition(collection, n)the collection split into non-overlapping chunks of length n.Partition(collection, n, d)overlapping sliding windows of length n, offset by d between windows.Partition(collection, {n1, n2, …}, d)a rank-k array cut into rectangular blocks of shape , offset by d (shared, or one per dimension) between windows — a matrix into overlapping 2×2 blocks, say.Partition(collection, n, d, {kL, kR}, pad?)sliding windows whose overhang past either end of the collection wraps around cyclically, or — with a trailing pad — is filled with pad instead.Typed signatures
| Type | Package | Applies |
|---|---|---|
(any, any, any?, any?, any?) -> any | combinatoricsreplaces compute-engine | always |
(indexed_collection<T>, ((T) any -> boolean) | integer, integer?) -> list<list<T>> where T: any | compute-engine | always |
Details
- Flatten undoes Partition: chunking and re-flattening recovers the original list — when the length divides evenly.
- With , windows overlap; the two-argument form is equivalent to , giving non-overlapping chunks.
- A ragged remainder, shorter than , is dropped rather than kept as a partial chunk.
- A list of sizes generalizes chunking to a rank-k array: each dimension gets its own window size (and, optionally, its own offset).
- The overhang pair pins where the first window starts and the last one ends, each counted from the near end of the collection — 1-based, negative counting from the far end of the WINDOW instead. Without a padding element, an overhang past either end wraps around cyclically.
Examples
2 more kept as data, checked against the oraclesBasic #
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
live ↗
InOut
About
| Examples | 40 |
|---|---|
| Checked against | Wolfram Language 40 agree |
| Crosswalk | WikipediaMathWorldWikidataBritannicaWolfram Language |