# list.range()

The `list.range()` function returns the list from the [`$list`](#usdlist) of range [`$from`](#usdfrom-1) to [`$to`](#usdto-list.length-usdlist).

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:list';

// Functions.
@use 'list.nth.function' as *;

// Modules.
@use '../math';

// The `list.range()` function.
@function range($list, $from: 1, $to: list.length($list)) {
  @return nth($list, (math.range(($from, $to, 1, 0)...) or $to)...);
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/list/_list.range.function.scss>" %}

### Parameters

#### **`$list`**&#x20;

The list to retrieve the elements from range [`$from`](#usdfrom-1) to [`$to`](#usdto-list.length-usdlist).

#### `$from: 1`

Index from which retrieving elements begins.

#### `$to: list.length($list)`

Index where the retrieval of elements ends.

### Return

The return value is the list of range [`$from`](#usdfrom-1) to [`$to`](#usdto-list.length-usdlist).

## Examples

```scss
// Use.
@use 'angular-package/sass/list';

// Examples.
// from - to
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), 2, 4); // "b", "c", "d"
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), 2, -1); // "b", "a", "f"
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), -1, 1); // "f", "a"
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), -6, -2); // "a", "b", "c", "d", "e"
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), 4, -4); // "d", "c", "b", "a", "f", "e", "d", "c"
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), 4, 9); // "d", "e", "f", null, null, null
@debug list.range(('a', 'b', 'c', 'd', 'e', 'f'), -1, -2); // "f", "e"

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.angular-package.dev/sass/list/list.range.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
