vector tag
Persistent logic tag
Stores a list of values.
Sample usage
<colours:vector {red}, {green}, {blue}> creates a vector of three elements.
<colours.push {yellow}> adds a fourth element at the end.
<colours.@ 2> generates {green}.
colours.# generates 4.
Fields
Primary field
Vector field
The list of values (elements). Elements are numbered from 1.
Secondary fields
- onPush: (code field) carried out when values are pushed into the vector.
- onPull: (code field) carried out when the vector's contents are pulled.
- onClear: (code field) carried out when the vector is cleared.
Behaviour
A vector creates an invisible tag instance holding a list of zero or more values.
- New values are added to the end with .push. Individual elements can't be changed in place: to change the list, assign a new list or clear it and push again.
- Assigning a new value to a vector (
<colours {black}>) clears it and then pushes the new values, so onClear and then onPush are carried out.
- Operators: .#, .@, .?, .push, .pull, .clear and .&. See Field Operators.
- Vector fields on other tags work in the same way, and support the same operators.
Notes
To display a vector's elements with separators between them, use join: <join colours delim={, }>.
See also