Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕BOX Vector ←→ Matrix
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕BOX Vector to/from Matrix


Converts a vector to a matrix, or a matrix to a vector using optional fill characters and line delimiters. ⎕BOX will only accept simple arguments.

One-argument form

In creating a matrix from a vector, ⎕BOX uses the space characters in the vector to determine the line breaks. It also uses the space character as a filler to make up the lines to the same length.

             ⎕BOX 'LEE PRENDERGAST PSMITH'
       LEE
       PRENDERGAST
       PSMITH

When ⎕BOX is used to convert a matrix into a vector it will treat the space character(s) at the end of each row as fillers, and will separate the original rows by spaces in the resultant vector:

             TAB
       APL
       LISP
       PASCAL
             ⎕BOX TAB
       APL LISP PASCAL

Two-argument form

The two argument form of ⎕BOX accepts one or two character left argument. The first character is used as the delimiter and the second the filler. If no filler is specified, the space character is used. In this example, ⎕BOX has a left argument of '*' and it uses '*' to determine breaks between lines:

             '*' ⎕BOX 'JAN FEB MAR* 1  2   3'
       JAN FEB MAR
        1   2   3

Here's an example with '.' used as the filler:

             '/.' ⎕BOX 'LEE/PRENDERGAST/PSMITH'
       LEE........
       PRENDERGAST
       PSMITH.....

In this next example, $ is treated as the delimiting character and the space character as the filler in the matrix TAB (defined above):

             '$' ⎕BOX TAB
       APL$LISP$PASCAL

If the matrix contains 'filler' symbols, these can be removed:

             NAMETAB
       LEE........
       PRENDERGAST
       PSMITH.....
             '$.' ⎕BOX NAMETAB
       LEE$PRENDERGAST$PSMITH

⎕BOX can also use numeric left and right arguments in the same way as character arguments. By default the delimiter and fill numbers are both 0.

             ⎕BOX 1 2 3 0 1 2
       1 2 3
       1 2 0
             ¯1 ¯6 ⎕BOX 2 3 4 ¯1 6 ¯1 ¯1 8 2
        2  3  4
        6 ¯6 ¯6
       ¯6 ¯6 ¯6
        8  2 ¯6

Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕BOX Vector ←→ Matrix
[ Previous | Next | Contents | Index | APL Home ]