---
title: "Creation of New Lists"
canonical: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/creation.html"
source: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/creation.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": "Construction of Lists", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/constructor.md"}
next: {"title": "Access Functions", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Lists/access.md"}
intrinsics:
  - {"name": "cat", "signature": "S cat T: List, List -> List"}
  - {"name": "cat:=", "signature": "S cat:= T: List, List"}
  - {"name": "Append", "signature": "Append(S, x): List, Elt -> List"}
  - {"name": "Append", "signature": "Append(~S, x): List, Elt"}
  - {"name": "Insert", "signature": "Insert(~S, i, x): List, RngIntElt, Any"}
  - {"name": "Insert", "signature": "Insert(S, i, x): List, RngIntElt, Any -> List"}
  - {"name": "Prune", "signature": "Prune(S): List -> List"}
  - {"name": "Prune", "signature": "Prune(~S): List"}
  - {"name": "SequenceToList", "signature": "SequenceToList(Q): SeqEnum -> List"}
  - {"name": "Seqlist", "signature": "Seqlist(Q): SeqEnum -> List"}
  - {"name": "TupleToList", "signature": "TupleToList(T): Tup -> List"}
  - {"name": "Tuplist", "signature": "Tuplist(T): Tup -> List"}
  - {"name": "Reverse", "signature": "Reverse(L): List -> List"}
---

# Creation of New Lists

Here, $S$ denotes the list ${[*}\ s_1, \ldots, s_n\ {*]}$, while $T$ denotes the list ${[*}\ t_1, \ldots, t_m\ {*]}$.

<a id="operation-operation-cat-list-list-list"></a>
## `S cat T: List, List -> List`

The list formed by concatenating the terms of the list $S$ with the terms of the list $T$, i.e. the list ${[*}\ s_1, \ldots, s_n, t_1,\ldots, t_m\ {*]}$.

<a id="operation-operation-cat-list-list"></a>
## `S cat:= T: List, List`

(Procedure.) Destructively concatenate the terms of the list $T$ to $S$; i.e. so $S$ becomes the list ${[*}\ s_1, \ldots, s_n, t_1,\ldots, t_m\ {*]}$.

<a id="function-append-list-elt"></a>
## `Append(S, x): List, Elt -> List`

The list formed by adding the object $x$ to the end of the list $S$, i.e. the list ${[*}\ s_1,\ldots s_n, x\ {*]}$.

<a id="procedure-append-list-elt-ref"></a>
## `Append(~S, x): List, Elt`

(Procedure.) Destructively add the object $x$ to the end of the list $S$; i.e. so $S$ becomes the list ${[*}\ s_1,\ldots s_n, x\ {*]}$.

<a id="procedure-insert-list-rngintelt-any-ref"></a>
## `Insert(~S, i, x): List, RngIntElt, Any`

<a id="function-insert-list-rngintelt-any"></a>
## `Insert(S, i, x): List, RngIntElt, Any -> List`

Create the list formed by inserting the object $x$ at position $i$ in $S$ and moving the terms $S[i], \ldots, S[n]$ down one place, i.e., the list ${[*}\ s_1, \ldots, s_{i-1}, x, s_{i}, \ldots, s_{n}\ {*]}$. Note that $i$ must not be bigger than $n+1$ where $n$ is the length of $S$. There are two versions of this: a procedure, where $S$ is replaced by the new list, and a function, which returns the new list. The procedural version takes a reference $\sim S$ to $S$ as an argument. Note that the procedural version is much more efficient since the list $S$ will not be copied.

<a id="function-prune-list"></a>
## `Prune(S): List -> List`

The list formed by removing the last term of the list $S$, i.e. the list ${[*}\ s_1$, $\ldots$, $s_{n-1}\ {*]}$.

<a id="procedure-prune-list-ref"></a>
## `Prune(~S): List`

(Procedure.) Destructively remove the last term of the list $S$; i.e. so $S$ becomes the list ${[*}\ s_1$, $\ldots$, $s_{n-1}\ {*]}$.

<a id="function-sequencetolist-seqenum"></a>
## `SequenceToList(Q): SeqEnum -> List`

<a id="function-seqlist-seqenum"></a>
## `Seqlist(Q): SeqEnum -> List`

Given a sequence $Q$, construct a list whose terms are the elements of $Q$ taken in the same order.

<a id="function-tupletolist-tup"></a>
## `TupleToList(T): Tup -> List`

<a id="function-tuplist-tup"></a>
## `Tuplist(T): Tup -> List`

Given a tuple $T$, construct a list whose terms are the elements of $T$ taken in the same order.

<a id="function-reverse-list"></a>
## `Reverse(L): List -> List`

Given a list $L$ return the same list, but in reverse order.
