# list.limit()

The `list.limit()` function returns the list from the first to [`$limit...`](#usdlimit...) index, or from the offset to the limit index.

{% code lineNumbers="true" %}

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

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

// The `list.limit()` function.
@function limit($list, $limit...) {
  @return range(
    $list,
    if(
        list.length($limit) == 1,
        list.join(1, $limit, comma),
        list.join(
          list.nth($limit, 1),
          calc(list.nth($limit, 1) + list.nth($limit, 2) - 1),
          comma
        )
      )...
  );
}
```

{% endcode %}

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

### Parameters

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

The list to retrieve the elements from, limited by the [`$limit`](#usdlist).

#### `$limit...`

A number of the indexes of the returned list from first, or given offset.

### Return

The return value is [`$list`](#usdlist) of elements specified in [`$limit...`](#usdlimit...).

## Examples

### Limit

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

// Examples.
// limit - number
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 1); // ("a",)
@debug list.limit(('27', '28', '29', 30), 2); // "27", "28"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2); // "a", "b"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 5); // "a", "b", "c", "d", "e"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 4); // "a", "b", "c", "d"

```

### Offset - limit

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

// Examples.
// offset - limit
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2, 5); // "b", "c", "d", "e", "f"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 1 4...); // "a", "b", "c", "d"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), 2 4...); // "b", "c", "d", "e"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), (2, 5)...); // "b", "c", "d", "e", "f"
@debug list.limit(('a', 'b', 'c', 'd', 'e', 'f'), (5, 3)...); // "e", "f", null

```


---

# 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.limit.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.
