WLJS LogoWLJS Notebook

Partition

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

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

Examples

Partition into pairs:

Partition[{a, b, c, d, e, f}, 2]
(* {{a, b}, {c, d}, {e, f}} *)

Overlapping partitions:

Partition[{1, 2, 3, 4, 5}, 3, 1]
(* {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}} *)

Please visit the official Wolfram Language Reference for more details.

On this page