Part

WMA link


Part[expr, i]

returns part i of expr.

Extract an element from a list:

Negative indices count from the end:

Part can be applied on any expression, not necessarily lists.

expr[[0]] gives the head of expr:

Parts of nested lists:

You can use Span to specify a range of parts:

A list of parts extracts elements at certain indices:

Get a certain column of a matrix:

Extract a submatrix of 1st and 3rd row and the two last columns:

The 3d column of a matrix:

Further examples:

Assignments to parts are possible:

Of course, part specifications have precedence over most arithmetic operations:

Most
Pick