SubVector()
Summary
Extracts a number of elements from a vector.
Changes
Added to Version 2014.
Syntax
sub_vector = SubVector(vector v, integer start, integer length)
| Argument | Contents |
|---|---|
| v | The input vector |
| start | The position of the first element extracted |
| length | The number of elements extracted |
Returns
A vector containing the specified elements of v, or null, if start and length do not specify any elements.
Notes
-
If start is null, SubVector() extracts from the beginning of v.
-
If length is null, SubVector() returns all the elements of the vector beginning with start.
-
SubVector() does not modify v; it creates a new vector containing a subset of the elements.
Example
a = {1,1,3,4,5}
v = a2v(a)
v2 = SubVector(v, 2, 3) // v2 = [1,3,4]
Error Codes
| Error Type | Meaning |
|---|---|
| Error | Start is less than one, or length is less than zero |
See Also
| Function | Summary |
|---|---|
| ArrayToVector() | Copies an array to a vector |
| CopyVector() | Copies a vector to a new vector |
| CumulativeVector() | Constructs a cumulative vector in a new vector |
| SortVector() | Sorts the elements of a vector in ascending order |
| SortVectors() | Sorts an array of vectors in ascending order, based on the first vector |
| TransposeArray() | Transposes an array of arrays, where element b[i][j] = a[j][i] |
| Vector() | Creates a vector |
| VectorToArray() | Copies a vector to an array |