setsubr - assign a value to a subrange of an array
arr.setsubr(beg0,
end0, ..., value)
The setsubr() method assign a value to 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 value must conform to the implied shape of the subrange, which is [end0-beg0+1,end1-beg1+1,...]. A scalar value will be replicated to every element of the subrange.
The setsubr method is equivalent to the
subrange assignment operator
arr[beg0:end0,
beg1:end1, ...] =
value. Note that the setsubr
method will be called to overload the subrange assignment operator.
None
TypeCheck if arr is not an object or
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.
a = [10, 20, 30, 40, 50]
a.setsubr(1, 3, 1000)
a
10 1000 1000 1000 50