# math.range()

The `math.range()` function returns the range of numbers.

{% code lineNumbers="true" %}

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

// Functions.
@use '../meta/meta.of-type.function';

// Modules.
@use 'range';

// The `math.range()` function.
@function range($from, $to, $step: 1, $except: null, $separator: auto) {
  @return if(
    meta.of-type(number, $from, $to, $step),
    if(
      $from < $to,
      range.up($from, $to, $step, $except, $separator),
      range.down($from, $to, $step, $except, $separator)
    ),
    null
  );
}
```

{% endcode %}

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

### Parameters

#### **`$from`**

The value of the `number` type indicates the beginning of the range.

#### **`$to`**

The value of `number` type indicates the end of the range.

#### **`$step: 1`**

The value of `number` type indicates each increment of the range. By default, it's **`1`**.

#### **`$except: null`**&#x20;

The value of a `number` or `list` of numbers not belonging to the range.

#### `$separator: auto`

A separator between the given range numbers.

### Return

The return value is the `list` of numbers from the given range.

## Examples

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

// Examples.
@debug math.range(15, 20); // 15 16 17 18 19 20
@debug math.range(20, 15); // 20 19 18 17 16 15

// step 2
@debug math.range(15, 20, 2); // 15 17 19

// to lower step 2
@debug math.range(15, -3, 2); // 15 13 11 9 7 5 3 1 -1 -3

// except
@debug math.range(15, -3, 1, 0); // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 -1 -2 -3
@debug math.range(15, -3, 1, 0 15 14); // 13 12 11 10 9 8 7 6 5 4 3 2 1 -1 -2 -3

// separator
@debug math.range(15, -3, 3, $separator: comma); // 15, 12, 9, 6, 3, 0, -3

```
