Debian Codegraph @

docs/integer_slice.md

raw
1 # Integer Slice Functions
2
3 ## until
4
5 The `until` function builds a range of integers.
6
7 ```
8 until 5
9 ```
10
11 The above generates the list `[0, 1, 2, 3, 4]`.
12
13 This is useful for looping with `range $i, $e := until 5`.
14
15 ## untilStep
16
17 Like `until`, `untilStep` generates a list of counting integers. But it allows
18 you to define a start, stop, and step:
19
20 ```
21 untilStep 3 6 2
22 ```
23
24 The above will produce `[3 5]` by starting with 3, and adding 2 until it is equal
25 or greater than 6. This is similar to Python's `range` function.
26
27 ## seq
28
29 Works 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 ```
35 seq 5 => 1 2 3 4 5
36 seq -3 => 1 0 -1 -2 -3
37 seq 0 2 => 0 1 2
38 seq 2 -2 => 2 1 0 -1 -2
39 seq 0 2 10 => 0 2 4 6 8 10
40 seq 0 -2 -5 => 0 -2 -4
41 ```