# 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"

```
