NAME

iterate - return an array of sequential integers starting from zero

SYNOPSIS

n->iterate()
shp.iterate()

DESCRIPTION

The iterate() method returns an array of the specified shape where each element is equal to its flattened row-major index.

If called on a scalar integer n, it returns a 1D vector of length n containing values from 0 to n-1.

If called on a vector shp, it returns an array with the shape specified by the vector, where each element is its row-major flattened index.

RETURN VALUE

An array of the specified shape containing sequential integers starting from 0.

ERRORS

TypeCheck if the input is not an integer or a vector of integers.

EXAMPLE

    5->iterate()
0 1 2 3 4

    [2, 3].iterate()
0 1 2
3 4 5

SEE ALSO

reshape
increment