Array - Function SummarySummary:Makes and initializes a series of a given size. Usage:array size Arguments:size - Size or block of sizes for each dimension (must be: integer block) Refinements:/initial - Specify an initial value for all elements value - Initial value Description:In REBOL, arrays are simply blocks that are initialized to a specific size with all elements set to an initial value (NONE by default). The ARRAY function is used to create and initialize arrays. Supplying a single integer as the argument to ARRAY will create an array of a single dimension. The example below creates a five element array with values set to NONE:
To initialize an array to values other than NONE, use the /INITIAL refinement. The example below intializes a block with zero values:
To create an array of multiple dimensions, provide a block of integers as the argument to the ARRAY function. Each integer specifies the size of that dimension of the array. (In REBOL, such multidimensional arrays are created using blocks of blocks.)
Once an array has been created, you can use paths or the PICK and POKE functions to set and get values of the block based on their indices:
Coding style note: REBOL uses the concept of expandable SERIES for holding and manipulating data, rather than the concept of fixed size arrays. For example, in REBOL you would normally write:
rather than:
In other words, REBOL does not require you to specify the size of data arrays (blocks, bytes, or strings) in advance. They are dynamic. Related:make - Constructs and returns a new value.
| |||||||||||||
|