Version 0.60.0
open

array

A one- or multidimensional array.

Signatures

  •   <dtype>[...]

Details

Array variables can store a one- or multidimensional list of elements of another data type dtype. The usage of arrays is described in more details in the section about arrays.

Multidimensional arrays are always rectangular, meaning that each dimension has a fixed size that spans over all elements.

Example

 int a[][] = [[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ],[ 10, 11, 12 ]]
 echo( a )
 echo( "length = " + a.length() )
 a.erase( 2 )
 echo( a )
 a.resize( 5 )
 echo( a )
 

Output

 <int>[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
 length = 4
 <int>[[1,2,3],[4,5,6],[10,11,12]]
 <int>[[1,2,3],[4,5,6],[10,11,12],[0,0,0],[0,0,0]]
 

Casts To

string

Members

int length()

Returns the size of the array, i.e. of its topmost dimension.

int erase( int n )

Removes the element with index n from the array. Returns the position that was erased. (Note that this operation has an asymptotic complexity of the number of elements after the one removed.)

int insert( int n, dtype e )

Adds an element e at position n of the array. This increases the array length by one. (Note that this operation has an asymptotic complexity of the number of elements after the one inserted.)

push_back( dtype e )

Adds an element e to the end of the array. This increases the array length by one.

resize( int size )

Changes the size of the array to a new size size. If this is smaller than the former size, the supernumerary elements are at the end of the array get deleted.

Optional Open Parameter Attributes

bool readonly

Tells the user interface or frontend to disable the setting of the open parameter.

string style

Specifies some limited styling instructions for the user interface or frontend.

int expose_opar

Controls the visibility state of the open parameter. Possible values are -1 (do not expose), 0 (expose when requested) and +1 (expose).

min

This attribute takes only effect if the array elements are of the int or float type. Then it acts like the min attribute of these data types on a per-element level. This means, that no elements of the array can have a value below min. This is enfored by the system.

max

This attribute takes only effect if the array elements are of the int or float type. Then it acts like the max attribute of these data types on a per-element level. This means, that no elements of the array can have a value above max. This is enfored by the system.

int maxlen

An integer value. If this is present, the array length is restricted to this.

See also

🗙

Search results for