Topic: APLX Help : Help on APL language : APL Primitives : ⍕ Format
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

Format


One-argument form  See also two-argument forms Format by specification, Format by example

, applied to any argument (character or numeric, simple or nested), converts it to characters according to the default display rules. (The formatted data may still look numeric since it is composed of the digits 0 to 9 together with suitable spaces and decimal points but it has the properties of character data and can be mixed in displays with other characters). The result is always a simple character array.

             QTY ← 1760 2
             ⍴ QTY                   (Asks the size of the data in QTY.
       2                              Answer is 2 numbers.)
             QTY ← ⍕ QTY             (Formats data in QTY.)
             ⍴ QTY                   (Asks the size of the data in QTY.
       6                              Answer is now 6 characters.)
             'PRICE IS ',⍕22×1.15    (The numeric data is formatted and joins the
       PRICE IS 25.3                  character data to form a simple character
                                      vector)
             DATA←(⍳3) (2 2⍴⍳4) 'TEXT' 100
             DATA
        1 2 3   1 2   TEXT 100
                3 4
             ⍴DATA
       4
             DATA←⍕DATA              (Format preserves the appearance of an
             DATA                     array, but makes it into a simple
        1 2 3   1 2   TEXT 100        character array)
                3 4
             ⍴DATA
       2 24

Topic: APLX Help : Help on APL language : APL Primitives : ⍕ Format
[ Previous | Next | Contents | Index | APL Home ]