# append

Inserts an element at the back of a list.

```tql
append(xs:list, x:any) -> list
```

## Description

The `append` function returns the list `xs` with `x` inserted at the end. The expression `xs.append(x)` is equivalent to `[...xs, x]`.

If `xs` is `null`, it is treated like an empty list, so `null.append(x)` returns `[x]`.

## Examples

### Append a number to a list

```tql
from {xs: [1, 2]}
xs = xs.append(3)
```

```tql
{xs: [1, 2, 3]}
```

### Append to a nullable list

```tql
from {xs: null}
xs = xs.append(3)
```

```tql
{
  xs: [
    3,
  ],
}
```

## See Also

* [`add`](https://preview.docs.tenzir.com/407/reference/functions/add.md)
* [`concatenate`](https://preview.docs.tenzir.com/407/reference/functions/concatenate.md)
* [`prepend`](https://preview.docs.tenzir.com/407/reference/functions/prepend.md)
* [`remove`](https://preview.docs.tenzir.com/407/reference/functions/remove.md)
* [Shape lists](https://preview.docs.tenzir.com/407/guides/transformation/shape-lists.md)