## Data

A data item is composed of numbers, characters, or references to objects. It can be a constant or a variable:

                 231           (constant)
                 NUM           (variable)

System variables are a special class of variable. Their names start with a Œ. Normally their initial values are set by the system, eg:

                 ŒPP

Data in APL is arranged in arrays. An array is a collection of data with a number of dimensions (rank) and a number of elements in each dimension (shape). Some or all of the elements may themselves be arrays, making the array a nested array with a third property, depth.

The commonest ranks of array are given special names:

                  Rank       Name        Dimensions

                    0        Scalar      None   (one element only)
                    1        Vector      1      (elements)
                    2        Matrix      2      (rows and columns)
                    3                    3      (planes, rows and columns)
                    4                    4      (blocks,planes,rows and columns)

Arrays of up to 63 dimensions are allowed in APLX.

The 'depth' of an array is a measure of the degree of nesting in the array. A simple (non-nested) scalar will have a depth of 0 and an array whose elements are all scalars (character or numeric) is known as a 'simple' array and has a depth of 1. In a nested array, the depth of the array is defined as the depth of the deepest element. The following table shows the way in which the depth of an array may be calculated:

                 Depth                  Description

                   0                     Simple scalar
                   1                     Simple array
                   2                     Deepest element in the array is of depth 1
                   3                     Deepest element in the array is of depth 2
                   .
                   n                     Deepest element in the array is of depth n-1

### Character Data

Anything enclosed between either single or double quotes is treated as character data (you must use the same type of quote mark to end the string as you use to begin it). This includes the digits, 0 to 9, and any of the symbols on the keyboard. It also includes the invisible character, space. If you have used single quotes to delimit the string, then to include a single quote itself in the character data, type it where it is required, followed immediately by another single quote. (Similarly for double quotes). Alternatively, if you use single-quotes to delimit a string, you can place double-quotes directly in the string without doubling them up, and vice-versa. The single- or double-quote characters used to surround character data are not displayed by APLX.

                 ALF„'ABC -+= 123'   (The characters in quotes are put in ALF)
                 ALF                 (When displayed, the quotes are dropped)
           ABC -+= 123

                 ½ALF                (½ is used to ask the size of ALF.
           11                         It contains 11 characters including spaces)

                 A„'DON''T WALK'     (' entered as ''
                 A
           DON'T WALK                 Only one is displayed)

                 A„"DON'T WALK"      (Alternative using double-quotes.
                 A
           DON'T WALK                 The result is the same)

                 B„ '''TIS TRUE '    (' as the first character of a text string)
                 B
          'TIS TRUE

                 B„ "'TIS TRUE "     (Alternative using double-quotes)
                 B
           'TIS TRUE

                 NUM„'501'           (Digits included in character data are
                 NUM+10               characters rather than numbers and
           DOMAIN ERROR               can't be used in arithmetic)

                 TABLE„3 6½"YES NO"
           YES NO                    (Character data can be formed into
           YES NO                     matrices. The six characters YES NO
           YES NO                     are formed into a matrix of 3 rows and
                                      6 columns)

Topic: APLX Help : Help on APL language : APL Fundamentals : Data

[ Previous |Next | Contents | Index ]