- vector append <vector> ?-contents? ?--?
- Appends the new elements to the end of the specified vector.
% vector append $v -contents {Q R S} % vector contents $v a b 1 2 X Y Q R S
- vector create ?-contents? ?--? ?<arg> ...?
- Creates a new vector containing the specified elements.
% set v [vector create a b 1 2 X Y] <feather::vector 0x200498d8> % vector contents $v a b 1 2 X Y
- vector contents <vector>
- Returns the contents of the vector as a list.
% vector contents $v a b 1 2 X Y Q R S
- vector insert <vector> ?-contents? ?--? <index> ?<arg> ...?
- Inserts the specified elements before the index'th element of the vector.
% vector insert $v 2 ! $ % vector contents $v a b ! {$} 1 2 X Y Q R S
- vector isa <vector>
- Tests whether the specified argument is a vector and returns 1 if it is and 0 if it is not.
% set v <feather::vector 0x200498d8> % vector isa $v 1 % vector isa "<feather::vector 0x200498d8>" 0
- vector narrow <vector> <start index> <end index>
- Discards any elements before the start index and after the end index. If the end index is before the start index this results in an empty vector.
% vector contents $v a b 1 2 X Y % vector narrow $v 1 4 % vector contents $v b 1 2 X
- vector prepend <vector> ?-contents? ?--? ?<arg> ...?
- Adds the new elements to the start of the specified vector.
% vector contents $v a b 1 2 X Y % vector prepend $v -contents {Q R S} % vector contents $v Q R S a b 1 2 X Y
- vector range <vector> <start index> <end index>
- Creates a new vector object which contains the elements from the start index to the end index inclusive. If the end index is before the start index this results in an empty vector.
% set v2 [vector range $v 2 7] <feather::vector 0x2004bea8> % vector contents $v2 S a b 1 2 X % vector append $v Z % vector contents $v2 S a b 1 2 X % vector contents $v Q R S a b 1 2 X Y Z
- vector remove <vector> <start index> <end index>
- Removes all the elements from the start index to the end index inclusive. If the end index is before the start index the vector is not affected.
% vector contents $v a b 1 2 X Y % vector remove $v 1 4 % vector contents $v a Y
- vector replace <vector> ?-contents? ?--? <start index> <end index> ?<arg> ...?
- Replaces all the elements from start index to end index inclusive with the new elements. This is equivalent to but more efficient than doing a remove followed by an insert of vice versa.
% vector contents $v a b 1 2 X Y % vector replace $v -contents 1 4 {9 8 7} {6 5 4} % vector contents $v a 9 8 7 6 5 4 Y
Flags
- -contents
- This flag indicates that rather than treat the arguments as elements to be added to the vector they are to be treated as containers and it is the contents of those containers which are to be added to the vector.
- --
- This flag indicates the end of the flags and should be used if there is a possibility that the first argument may start with a - and would therefore be treated as a flag.
IndecesVector indices have the following meanings.
- negative integers
- These are relative to the element one past the end of the vector. They are converted to indeces relative to the start of the vector by adding the length of the vector. If after this conversion the index is still negative then it is set to be 0.
- positive integers
- These are relative to the start of the vector. If they are greater than or equal to the length of the vector they correspond to the last element in the vector.
- end
- This corresponds to the last element in the vector or one past the last element depending on its uses.