Accessing elements

### 3.2.4 Accessing elements

The elements of sequences and lists are indexed starting from 0 in Xcas syntax mode and from 1 in all other syntax modes (see Section 2.5.2). To access an element of a list or a sequence, follow the list with the index between square brackets.

#### Examples

L:=[2,5,1,4]

| ⎡ ⎣ | 2,5,1,4 | ⎤ ⎦

L[1]

5 |  |  |  |  |  |  |  |  |  |

To access the last element of a list or sequence, you can put -1 between square brackets.

L[-1]

4 |  |  |  |  |  |  |  |  |  |

If you want the indices to start from 1 in Xcas syntax mode, you can enter the index between double brackets.

L[[1]]

2 |  |  |  |  |  |  |  |  |  |