range

pure constructor(end: integer)

Construct a range, starting at 0 (inclusive), ending at end (exclusive), with a step size of 1.

Examples:

  • list(range(0)) returns [].

  • list(range(1)) returns [0].

  • list(range(2)) returns [0, 1].

  • list(range(10)) returns [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].

Note that range(x) is equivalent to range(0, x, 1).

Since

0.6.0

Parameters

end

end value (exclusive) for this range

Throws

exception

if end < 0


pure constructor(start: integer, end: integer, [step: integer])

Construct a range, starting at start (inclusive), ending at end (exclusive), with a "step size" (i.e. difference between consecutive values) of step.

If start > end, then step must be negative. Conversely, if start < end, the step must be positive. step cannot be 0.

Examples:

  • list(range(1, 23, 3)) returns [1, 4, 7, 10, 13, 16, 19, 22].

  • list(range(20, 1, -2)) returns [20, 18, 16, 14, 12, 10, 8, 6, 4, 2].

  • list(range(-2, -8, -1)) returns [-2, -3, -4, -5, -6, -7].

  • list(range(3, 3, 7)) returns []. Indeed, for all x, and for all y != 0, range(x, x, y) returns [].

Note that range(0, x, 1) is equivalent to range(x).

Since

0.6.0

Parameters

start

start value for this range (inclusive)

end

end value for this range (exclusive)

step

step size for this range

Throws

exception

when:

  • step == 0

  • start > end and step > 0

  • start < end and step < 0