]>
The FlexibleArray domain constructor creates one-dimensional arrays of elements of the same type. Flexible arrays are an attempt to provide a data type that has the best features of both one-dimensional arrays (fast, random access to elements) and lists (flexibility). They are implemented by a fixed block of storage. When necessary for expansion, a new, larger block of storage is allocated and the elements from the old storage area are copied into the new block.
Flexible arrays have available most of the operations provided by OneDimensionalArray (see OneDimensionalArrayXmpPage and VectorXmpPage ). Since flexible arrays are also of category ExtensibleLinearAggregate, they have operations concat!, delete!, insert!, merge!, remove!, removeDuplicates!, and select!. In addition, the operations physicalLength and physicalLength! provide user-control over expansion and contraction.
A convenient way to create a flexible array is to apply the operation flexibleArray to a list of values.
Create a flexible array of six zeroes.
For set the -th element to . Display f.
Initially, the physical length is the same as the number of elements.
Add an element to the end of f.
See that its physical length has grown.
Make f grow to have room for 15 elements.
Concatenate the elements of f to itself. The physical length allows room for three more values at the end.
Use insert! to add an element to the front of a flexible array.
Create a second flexible array from f consisting of the elements from index 10 forward.
Insert this array at the front of f.
Merge the flexible array f into g after sorting each in place.
Remove duplicates in place.
Remove all odd integers.
All these operations have shrunk the physical length of f.
To force Axiom not to shrink flexible arrays call the shrinkable operation with the argument false. You must package call this operation. The previous value is returned.