NAME

subr - return a subrange of an array

SYNOPSIS

arr.subr(beg0, end0, ...)

DESCRIPTION

The subr() method returns a subrange of the array arr. The arguments are provided in pairs begN, endN, where begN is the starting index and endN is the ending index (inclusive) for the Nth dimension. If nil is provided for begN, it defaults to 0. If nil is provided for endN, it defaults to the last index of that dimension. The subrange is clamped to the actual bounds of the array or string. If endN is less than begN the result is an empty array or string.

The new substring or subarray is a copy, NOT part of the original string or array; therefore, modifying its contents will not modify the original object.

RETURN VALUE

An array containing the specified subrange.

ERRORS

TypeCheck if arr is not an array.
ArgCheck if an odd number of index arguments is provided.
RangeCheck if an index is out of bounds or if too many index pairs are provided.

EXAMPLE

    a = {10, 20, 30, 40, 50}
    a.subr(1, 3)
20 30 40

    a.subr(2, nil)
30 40 50

SEE ALSO

reshape
take
drop