---
title: "List Functions"
description: "A list of list (ListAccum) functions in GSQL."
component: "gsql-ref"
version: "4.3"
module: "querying"
html_url: "/gsql-ref/4.3/querying/func/list-functions"
canonical_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/list-functions"
markdown_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/list-functions.md"
---

[View as HTML](https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/list-functions)

# List Functions

This page lists the list (ListAccum) functions that are available in the GSQL query language.

## `head()`

### Syntax

`head(list)`

### Description

`head()` returns the first element in a list. It is semantically the same as `list.get(0)`

### Return type

`ELEMENT`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `list` | A ListAccum parameter, where we want to retrieve the first element in the list | `ListAccum<ELEMENT>` |

### Example

```text
head(["a", "b", "c"]) -> "a"
```

## `last()`

### Syntax

`last(list)`

### Description

`last()` returns the last element in a list. It is semantically the same as `list.get(list.size() - 1)`

### Return type

`ELEMENT`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `list` | A ListAccum parameter, where we want to retrieve the last element in the list | `ListAccum<ELEMENT>` |

### Example

```text
last(["a", "b", "c"]) -> "c"
```

## `range()`

### Syntax

`range(start, end [, step])`

### Description

`range()` returns a `ListAccum` of integer values within a range bounded by a start value `start` and end value `end`, and an optional step size `step`. The range is inclusive, so the arithmetic progression will always contain `start`, and it may contain \`end\`value, depending on the step size.

### Return type

`ListAccum<INT>`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `start` | The starting value of the range | `UINT`, `INT` |
| `end` | The ending value of the range | `UINT`, `INT` |
| `step` | (Optional) The difference between any two consecutive values in the range | `UINT`, `INT` |

### Example

```text
range(0, 5) -> [0, 1, 2, 3, 4, 5]
range(5, 0, -1) -> [5, 4, 3, 2, 1, 0]
range(2, 18, 3) -> [2, 5, 8, 11, 14, 17]
```

> [!NOTE]
> * The range() function creates a ListAccum, which uses more memory compared to the traditional RANGE\[expr, expr\] method used in FOREACH.
> * For large ranges, the range() function can consume significant memory, as it generates the entire list before iteration.

## `size()`

### Syntax

`size(list)`

### Description

`size()` returns the number of elements in a `ListAccum`

### Return type

`UINT`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `list` | A ListAccum parameter | `ListAccum<ELEMENT>` |

### Example

```text
size(["a", "b", "c"]) -> 3
```

## `split()`

### Syntax

`split(original, splitDelimiter)`

### Description

`split()` returns a list of strings resulting from the splitting of the original string on matches of the given delimiter.

### Return type

`ListAccum<STRING>`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `original` | The original string to split | `STRING` |
| `splitDelimiter` | The delimiter to split the original string on | `STRING` |

### Example

```text
split("one,two", ",") -> ["one", "two"]
split("aaabcaabca", "abc") -> ["aa", "a", "a"]
```

## `tail()`

### Syntax

`tail(list)`

### Description

`tail()` returns the copy of the list that includes all but the first element in the parameter list.

### Return type

`ListAccum<ELEMENT>`

### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `list` | A ListAccum parameter | `ListAccum<ELEMENT>` |

### Example

```text
tail(["a", "b", "c"]) -> ["b", "c"]
```
