Vector Functions

Summary
Get how many elements are in the vector.
Create a new vector containing a copy of each element in the source vector.
Break a string into parts using a substring delimiter.
Separate a string using a set of character delimiters.
Extract the words of a string into a vector.
Join the elements of a vector with a string.
Remove the first element in a vector and return its value as an integer.
Remove the first element in a vector and return its value as a string.
Insert a new integer on the front of a vector.
Insert a new string on the front of a vector.
Remove an element from the end of a vector and return its value as an integer.
Remove an element from the end of a vector and return its value as a string.
Insert an integer at the end of a vector.
Insert a string as the end of a vector.
Inesrt an integer value in the middle of a vector.
Insert a string value in the middle of a vector.
Remove an element from a vector.
Remove an element from a vector.
Remove all the elements from a vector.
Sorts the vector using string comparison.
Sorts the vector using numeric comparison.
Returns the vector in reversed order.

size

Get how many elements are in the vector.

Params

v@the vector

Returns

An integer count of the number of elements in the vector.

clone@

Create a new vector containing a copy of each element in the source vector.

This has no practical effect, and is provided for compatibility only.

Params

v@the vector

Returns

A copy of the vector and each element in it.

split@

Break a string into parts using a substring delimiter.

Params

str$the source string
sep$a substring delimiter

Returns

Each part of the string between delimiters is returned in a new vector.

splitc@

Separate a string using a set of character delimiters.  Break the string using any of the given characters as a delimiter.  Subsequent delimiter characters are merged and treated as one delimiter.

splitc@("abc|:|xyz", ":|") = [ "abc", "xyz" ]

Note the similarity of this function to words$()’s behavior.  The following two expressions are equivalent.

words$(str$, 2, 2)
splitc@(str$, " \t\n")[2]$

Params

str$the source string
delims$a string of characters to used as delimiters

Returns

Each part of the string between delimiters in a new vector.

words@

Extract the words of a string into a vector.

Params

str$the source string

Returns

A vector containing the words in the string.

join$

Join the elements of a vector with a string.  The ‘glue’ is inserted between each element and the result is concatenated into a single string.

Params

v@the vector whose elements should be joined
glue$the string to use when joining elements

Returns

A string obtained by concatenating each element with glue$ between each.

shift

Remove the first element in a vector and return its value as an integer.

Params

v@the vector

Returns

An integer (0 if there are no more elements).

shift$

Remove the first element in a vector and return its value as a string.

Params

v@the vector

Returns

A string (“” if there are no more elements).

unshift

Insert a new integer on the front of a vector.

Params

v@the vector
valuethe value to insert

Returns

nothing

unshift

Insert a new string on the front of a vector.

Params

v@the vector
value$the value to insert

Returns

nothing

pop

Remove an element from the end of a vector and return its value as an integer.

Params

v@the vector

Returns

An integer (0 if there are no more elements).

pop$

Remove an element from the end of a vector and return its value as a string.

Params

v@the vector

Returns

A string (“” if there are no more elements).

push

Insert an integer at the end of a vector.

Params

v@the vector
valuethe value to insert

Returns

nothing

push

Insert a string as the end of a vector.

Params

v@the vector value$- the value to insert

Returns

nothing

insert

Inesrt an integer value in the middle of a vector.

Params

v@the vector
indexthe spot to insert the new element at
valuethe value to insert

Returns

nothing

insert

Insert a string value in the middle of a vector.

Params

v@the vector
indexthe spot to insert the new element at
value$the value to insert

Returns

nothing

delete

Remove an element from a vector.

Params

v@the vector
indexthe element to remove

Returns

the removed element, or 0

delete$

Remove an element from a vector.

Params

v@the vector
indexthe element to remove

Returns

the removed element, or “”

clear

Remove all the elements from a vector.

Params

v@the vector

Returns

nothing

sort@

Sorts the vector using string comparison.

This function returns the sorted vectorthe original vector is NOT modified.

Params

v@the vector

Returns

sorted vector

nsort@

Sorts the vector using numeric comparison.  String values are treated as zeroes, and their relative ordering is preserved.

This function returns the sorted vectorthe original vector is NOT modified.

Params

v@the vector

Returns

sorted vector

reverse@

Returns the vector in reversed order.  The original vector is not modified.

Params

v@the vector

Returns

reversed vector