range

start:end

start:step:end

range(start, end)

range(start, end, step)

range(string)

Try it yourself:


range(): Building Number Sequences

range() creates a sequence of values, usually from a start to an end with an optional step. It is useful for indices, sample positions, grids, and repeatable test data.

Endpoints and steps

Specify a step whose sign can reach the endpoint: a positive step cannot traverse downward. A zero step is invalid because it never progresses. Check output length with size(), then transform values using map() or aggregate them with sum().

Decimal steps can accumulate floating-point error. For exact indexed loops, create integer positions then scale them with multiply(). Use randomInt() instead when the goal is sampling rather than enumeration.

All functions