...

Text file src/github.com/go-task/slim-sprig/v3/docs/integer_slice.md

Documentation: github.com/go-task/slim-sprig/v3/docs

     1# Integer Slice Functions
     2
     3## until
     4
     5The `until` function builds a range of integers.
     6
     7```
     8until 5
     9```
    10
    11The above generates the list `[0, 1, 2, 3, 4]`.
    12
    13This is useful for looping with `range $i, $e := until 5`.
    14
    15## untilStep
    16
    17Like `until`, `untilStep` generates a list of counting integers. But it allows
    18you to define a start, stop, and step:
    19
    20```
    21untilStep 3 6 2
    22```
    23
    24The above will produce `[3 5]` by starting with 3, and adding 2 until it is equal
    25or greater than 6. This is similar to Python's `range` function.
    26
    27## seq
    28
    29Works like the bash `seq` command.
    30* 1 parameter  (end) - will generate all counting integers between 1 and `end` inclusive.
    31* 2 parameters (start, end) - will generate all counting integers between `start` and `end` inclusive incrementing or decrementing by 1.
    32* 3 parameters (start, step, end) - will generate all counting integers between `start` and `end` inclusive incrementing or decrementing by `step`.
    33
    34```
    35seq 5       => 1 2 3 4 5
    36seq -3      => 1 0 -1 -2 -3
    37seq 0 2     => 0 1 2
    38seq 2 -2    => 2 1 0 -1 -2
    39seq 0 2 10  => 0 2 4 6 8 10
    40seq 0 -2 -5 => 0 -2 -4
    41```

View as plain text