15
edits
Chris-barry (talk | contribs) (→size()) |
Chris-barry (talk | contribs) (→subvec(): The previous description began with a statement that was incorrect and then gave no further description. The examples are trivial but that probably does not justify removing them.) |
||
Line 50: | Line 50: | ||
== subvec() == | == subvec() == | ||
Create a new vector comprising elements from a contiguous range of elements of an existing vector. | |||
'''Usage:''' | |||
subvec([''vect'', [''start'', [''count'']]]) | |||
<dl> | |||
<dt>''vect''</dt> | |||
<dd>The original vector</dd> | |||
<dt>''start''</dt> | |||
<dd>The zero-based index in the original vector of the first element to be copied.</dd> | |||
<dt>''count''</dt> | |||
<dd>The number of elements to copy. If this argument is omitted then ''size(vect) - start'' is assumed.</dd> | |||
</dl> | |||
'''Return value''' | |||
A new vector containing the specified range from the original vector, or ''nil''. | |||
'''Notes:''' | |||
<ol> | |||
<li> | |||
Omitting the ''vect'' and ''start'' arguments is not an error (possibly it should be) but the return value is ''nil''. | |||
</li> | |||
<li> | |||
A negative ''start'' argument '''is'' an error. This seems wrong. Perhaps the language designer could comment. | |||
</li> | |||
<li> | |||
A value of ''start'' greater than ''size(vect)'' causes an error. A value equal to ''size(vect)'' returns an empty vector. | |||
</li> | |||
<li> | |||
If the value of ''count'' is greater than ''size(vect) - start'' then it is ignored. That is, all elements from ''start'' to the end of ''vect'' are returned. A negative value of ''count'' causes an error. | |||
</ol> | |||
Example : | Example : |
edits