Investment Studio > Expressions > Arrays

Arrays are used to create single expressions which produce multiple results or operate on multiple arguments. Many functions and operators support arrays or can be applied to all elements in an array using the MOP function.

There are three types of arrays: cell ranges, explicit arrays and array-valued cells. All three can mix elements of different data types freely.

Cell ranges

A cell range is the classic spreadsheet adaptation of the array concept. It's just a rectangular block of cells, serving as a single operand or argument in an expression. In practice, cell ranges exist only as references created with the range operator (:). Apart from the simple spreadsheet in the Macros view, they are of little use in Investment Studio.

Example:

Here, the SUM function is used to add up the values in the cell range spanned by corner cells B1 and C2.

Explicit arrays

An explicit array is a group of values (expressions or constants) sandwiched between curly brackets and separated by the list separator character.

The list separator character depends on the computer's regional settings. It's typically a comma (,) or a semicolon (;). In this document, a comma is used.
Example:

{1, 10, 100}

is a 1-dimensional constant array. You can use the simple spreadsheet in the Macros view and the INDEX function to convince yourself that it's a row vector (one row, multiple columns):

=index({1, 10, 100}, 1, 3)

returns the value of row 1, column 3 as 100.

Array elements are numbered 1, 2, 3... i.e. there is never a 0th element.
Example: A column vector (one column, multiple rows) with the same elements as in the previous example is written

{{1}, {10}, {100}}

or equivalently, using the TRANSPOSE function,

=transpose({1, 10, 100})

To remember the layout of elements in explicit arrays, think "closing bracket = new row".
Example:

={{1, =1 + 1}, {sqrt(9)}}

is a 2-dimensional array. Note the absence of a leading "=" in the last expression (it's implied; including it is optional). Also note that there are two columns in the first row, but only one column in the second row.

Arrays need not be rectangular: different rows can have different numbers of columns.

While nothing prevents you from creating arrays with more than two dimensions, there are no built-in operators or functions capable of accessing the values in such arrays.

Array-valued cells

Assigning an array to a cell (e.g. in a Grid object or in the Macros spreadsheet) makes it an array-valued cell. On inspection, such a cell looks just like an ordinary cell. It displays the value of the first array element:

The same value is returned by ordinary references to the cell:

The rest of the array is hidden "under the surface", iceberg-like, but can be accessed using the ARRAY function.