---
title: "Access Functions"
canonical: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/access.html"
source: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/access.md"
part: "Sets, Sequences, and Mappings"
chapter: "Lists"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Sets, Sequences, and Mappings", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/index-sets-sequences-mappings.md"}
  - {"title": "Lists", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/index-lists.md"}
prev: {"title": "Creation of New Lists", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/creation.md"}
next: {"title": "Assignment Operator", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/assignment.md"}
intrinsics:
  - {"name": "#", "signature": "# S: List -> RngIntElt"}
  - {"name": "IsEmpty", "signature": "IsEmpty(S): List -> BoolElt"}
  - {"name": "S[i]", "signature": "S[i]: List, RngIntElt -> Elt"}
  - {"name": "S[I]", "signature": "S[I]: List, [RngIntElt] -> List"}
  - {"name": "IsDefined", "signature": "IsDefined(L, i): List, RngIntElt -> Elt"}
---

# Access Functions

<a id="operation-operation-list-rngintelt"></a>
## `# S: List -> RngIntElt`

The length of the list $S$.

<a id="function-isempty-list"></a>
## `IsEmpty(S): List -> BoolElt`

Return whether $S$ is empty (has zero length).

<a id="literal-literal-s-i-list-rngintelt-elt"></a>
## `S[i]: List, RngIntElt -> Elt`

Return the $i$-th term of the list $S$. If either $i \leq 0$ or $i > \#S + 1$, then an error results. Here $i$ is allowed to be a multi-index (see Section [Multi-indexing](https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/IntroductionToAggregates/nesting.md#aggr-multi-ind) for the interpretation).

<a id="literal-literal-s-i-list-rngintelt-list"></a>
## `S[I]: List, [RngIntElt] -> List`

Return the sublist of $S$ given by the indices in the sequence $I$. Each index in $I$ must be in the range $[1..l$], where $l$ is the length of $S$.

<a id="function-isdefined-list-rngintelt"></a>
## `IsDefined(L, i): List, RngIntElt -> Elt`

Checks whether the $i$th item in $L$ is defined or not, that is it returns `true` if $i$ is at most the length of $L$ and `false` otherwise.
