Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕DISPLAY Display Array Structure
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕DISPLAY Display Array Structure


The monadic system function ⎕DISPLAY returns a character matrix which shows the structure of an APL array. It is equivalent to the DISPLAY function supplied with previous versions of APLX and APL.68000, and with many other APL interpreters. It takes any APL expression as its argument, and returns a character matrix which is the formatted array with symbols showing the structure and nesting.

Note: In desktop editions of APLX, you can invoke a Display Window to show array structure, using the pop-up menu which appears when you right-click (or, under MacOS, click-and-hold) over a variable name. For named variables, you can also use the )DISPLAY system command. In both cases the array structure is shown in the same form as shown here.

⎕DISPLAY takes the data or expression whose value is to be examined as a right argument. For example:

        ⎕DISPLAY 1 2 3

The output from ⎕DISPLAY shows the data with boxes around it. The output can have one or many boxes inside the perimeter box. Also you will see that the characters at the left hand end of the top and bottom lines and those at the top of the left side line will change for different data types. It is these boxes and their embedded characters which inform you of the specific structure of the data being examined.

The symbols indicate the type of variable contained within the box while the number of boxes within boxes shows the depth of the data. Here are some simple examples:

     ⎕DISPLAY 3 7 8
┌→────┐
│3 7 8│
└~────┘

This first example is a simple 1 dimensional vector. This is indicated by the absence of an arrow on the left hand side of the box showing that there is no organisation along this axis, only along the horizontal axis as shown by the right pointing arrow at the top of the box. The '~' symbol at the bottom of the box indicates numeric data.

     ⎕DISPLAY 3 4⍴⎕A
┌→───┐
↓ABCD│
│EFGH│
│IJKL│
└────┘

This second example shows a two dimensional (rank 2) character matrix. The right arrow and the down arrow indicate two dimensions, while the absence of the '~' character indicates text or character elements.

Here is a summary of the special characters and their meanings:

    |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
    |  Placement on box   |              Meaning               |
 ___|_____________________|____________________________________|
|   |                     |                                    |
| - | Beneath a character | Scalar character                   |
| → | Left of top edge    | Vector or higher-rank array        |
| ~ | Left of bottom edge | Numeric data                       |
| + | Left of bottom edge | Mixed data                         |
| ⊖ | Left of top edge    | Empty vector or higher-rank array  |
| ↓ | Left side of box    | Matrix or higher-rank array        |
| ⌽ | Left side of box    | Empty matrix or higher-rank array  |
| ∊ | Left of bottom edge | Nested array                       |
|___|_____________________|____________________________________|

Where an array is empty, this is shown by the '⌽'character on the left side of the box or the '⊖'character on the top side, and the prototype of the array is shown inside the box.

Examples

      ⎕DISPLAY (3 4 5) 6 (9 9)
┌→────────────────┐
│ ┌→────┐   ┌→──┐ │
│ │3 4 5│ 6 │9 9│ │
│ └~────┘   └~──┘ │
└∊────────────────┘

The '∊' is on the outside box because the data within is nested. The inner boxes however have '~' characters showing that within these smaller boxes only numeric data exists. The depth of the data is two:

      ≡ (3 4 5) 6 (9 9)
2

This can be read from the display by counting the greatest number of nested boxes, two.

      ⎕DISPLAY 'A'                  ⍝ Character scalar
 A
 ¯
      ⎕DISPLAY 1                    ⍝ Numeric scalar
 1

(Note here that there is no need for a complete box with scalars)

      ⎕DISPLAY ⍳0                   ⍝ Empty numeric vector
┌⊖┐
│0│
└~┘

      ⎕DISPLAY 'A B C D E F'          ⍝ Character vector
┌→──────────┐
│A B C D E F│
└───────────┘

      ⎕DISPLAY 3 4⍴1 2 3 4 5          ⍝ 2-dimensional numeric matrix
┌→──────┐
↓1 2 3 4│
│5 1 2 3│
│4 5 1 2│
└~──────┘

      ⎕DISPLAY 1 1 1 2 5⍴'MICRO APL '   ⍝ Multi-dimensional character matrix
┌┌┌┌→────┐
↓↓↓↓MICRO│
││││ APL │
└└└└─────┘


      ⎕DISPLAY 2 4 5⍴⍳30                 ⍝ 3-dimensional numeric matrix
┌┌→─────────────┐
↓↓ 1  2  3  4  5│
││ 6  7  8  9 10│
││11 12 13 14 15│
││16 17 18 19 20│
││              │
││21 22 23 24 25│
││26 27 28 29 30│
││ 1  2  3  4  5│
││ 6  7  8  9 10│
└└~─────────────┘

      ⎕DISPLAY 1 2 3 'A' 4 5 6               ⍝ Mixed vector
┌→─────────────┐
│1 2 3 A 4 5 6 │
└+─────────────┘

(Note the plus sign in the bottom left denoting mixed data)

      ⎕DISPLAY (1 2 3 4) (50 60 70) (89 99 109)  ⍝ Nested vectors
┌→─────────────────────────────────┐
│ ┌→──────┐ ┌→───────┐ ┌→────────┐ │
│ │1 2 3 4│ │50 60 70│ │89 99 109│ │
│ └~──────┘ └~───────┘ └~────────┘ │
└∊─────────────────────────────────┘

      ⎕DISPLAY (2 3⍴⍳6) (1 1⍴1) (1 2 2⍴⍳4)       ⍝ Nested matricies
┌→───────────────────┐
│ ┌→────┐ ┌→┐ ┌┌→──┐ │
│ ↓1 2 3│ ↓1│ ↓↓1 2│ │
│ │4 5 6│ └~┘ ││3 4│ │
│ └~────┘     └└~──┘ │
└∊───────────────────┘

      ⎕DISPLAY ⊂'G H I J',(⊂'K L M N') (3 2⍴⎕D)  ⍝ Nested (⎕D is character)
┌──────────────────────────────────────┐
│ ┌→─────────────────────────────────┐ │
│ │               ┌───────────┐ ┌→─┐ │ │
│ │ G   H   I   J │ ┌→──────┐ │ ↓01│ │ │
│ │ - - - - - - - │ │K L M N│ │ │23│ │ │
│ │               │ └───────┘ │ │45│ │ │
│ │               └∊──────────┘ └──┘ │ │
│ └∊─────────────────────────────────┘ │
└∊─────────────────────────────────────┘


      ⎕DISPLAY ⊂⊂⊂(3 4⍴⎕A) (2 3 7⍴⍳42),'A'       ⍝ Mixed nested matrices
┌──────────────────────────────────────────────┐
│ ┌──────────────────────────────────────────┐ │
│ │ ┌──────────────────────────────────────┐ │ │
│ │ │ ┌→─────────────────────────────────┐ │ │ │
│ │ │ │ ┌→───┐ ┌┌→───────────────────┐   │ │ │ │
│ │ │ │ ↓ABCD│ ↓↓ 1  2  3  4  5  6  7│ A │ │ │ │
│ │ │ │ │EFGH│ ││ 8  9 10 11 12 13 14│ - │ │ │ │
│ │ │ │ │IJKL│ ││15 16 17 18 19 20 21│   │ │ │ │
│ │ │ │ └────┘ ││                    │   │ │ │ │
│ │ │ │        ││22 23 24 25 26 27 28│   │ │ │ │
│ │ │ │        ││29 30 31 32 33 34 35│   │ │ │ │
│ │ │ │        ││36 37 38 39 40 41 42│   │ │ │ │
│ │ │ │        └└~───────────────────┘   │ │ │ │
│ │ │ └∊─────────────────────────────────┘ │ │ │
│ │ └∊─────────────────────────────────────┘ │ │
│ └∊─────────────────────────────────────────┘ │
└∊─────────────────────────────────────────────┘

      ⎕DISPLAY 0⍴(2 2⍴⍳4) ('PERSIMMON')        ⍝ Empty nested vector
┌⊖──────┐
│ ┌→──┐ │
│ ↓0 0│ │
│ │0 0│ │
│ └~──┘ │
└∊──────┘

(Note that the prototype of the array is shown in the box)


Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕DISPLAY Display Array Structure
[ Previous | Next | Contents | Index | APL Home ]