util.lists.range
Generates a list of decimal values in a range from start
(inclusive) up to stop
(exclusive) in increments of step
. This is similar to Python's built-in range
, but the returned values are stored as sneq decimals.
def range(
start: dec, int, or None = None,
stop: dec, int, or None = None,
step: dec, int, or None = None,
) -> list
- start: The starting value (default
0
ifstop
is given andstart
is omitted). - stop: The stopping value (exclusive).
- step: The increment (default
1
if omitted). Cannot be0
.
Behavior:
- If only
stop
is provided (andstart
isNone
), the sequence is[0, 1, 2, ..., stop - 1]
. - If
start
andstop
are provided butstep
is not, the step defaults to1
. - If
start
,stop
, andstep
are all provided, it uses the standard(start, stop, step)
iteration. - If
stop
isNone
(or not provided), an empty list is returned.
Example:
# range(stop=5) -> [0, 1, 2, 3, 4]
nums = util.lists.range(stop=5)
# range(start=2, stop=5) -> [2, 3, 4]
nums = util.lists.range(start=2, stop=5)
# range(start=0, stop=10, step=2) -> [0, 2, 4, 6, 8]
nums = util.lists.range(start=0, stop=10, step=2)
# If none of (start, stop, step) are provided, returns [].
nums = util.lists.range() # -> []