Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1488 |
|
Package | general | |
Module | quanta |
a | in | initial filling value(s) | |
Allowed: | any or array of any | ||
Default: | empty record | ||
... | in | coordinate lengths for each dimension | |
Allowed: | non-zero integer | ||
id | in | optional record id | |
Allowed: | string |
r_array creates an array of records. Record arrays were introduced to be able to communicate arrays/vectors of arbitrary data types to and from C++ code. Most special records (quanta, measures, skycomponents etc.) will have an id attribute to identify them across the system, but this id is not essential. Arrays of records have always a shape attribute, to distinguish them from a 'scalar' record. They are created in the same way as normal Glish arrays (except using r_array). The function accepts an additional, optional, argument to set an id if wanted. A vector with length one is assumed to be a scalar (a multidimensional array with 1 element will be an array).
- print a := r_array(1:5, 2, 3) # create an array [*3=1, *4=2, *5=3, *6=4, *7=5, *8=1] - a:: # show the attributes [shape=[2 3] ] - print a := r_array(1:5, 2, 3, id='quant') # another [*9=1, *10=2, *11=3, *12=4, *13=5, *14=1] - a:: # and its attributes [id=quant, shape=[2 3] ] - r_array(a,1) # a 'scalar' 1 - r_array(a,2,1) # initial with record array [*17=1, *18=2]