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.

Try Range in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions