Algosim documentation: range

range

Creates a range structure.

Syntax

Description

If a, b, and k are integers, then range(a, b, k) returns the structure

from:  a
to:    b
step:  k

of type IntRange.

If omitted, b defaults to a, and k to 1, so that range(a, b) returns

from:  a
to:    b
step:  1

and range(a) returns

from:  a
to:    a
step:  1.

IntRange structures are used as input to some function, notably part, and specify ranges of indices. Typically, if a ≤ b, then range(a, b) means all indices from a to b (inclusively), so that range(a) means the single index a. Indices typically can be given both as positive numbers (counting from the first index) or as negative numbers (counting from the last index), and if b denotes an index preceding a, then part(a, b) denotes the indices from b to a in reverse order. If step > 1, only every stepth index will be included. Usually, it doesn’t make sense for step to be non-positive.

See part for examples.

See also