>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary

Format 8!:

[x] 8!:0 y Format. Format array y according to format phrases x . Each formatted number is in a box.
 
[x] 8!:1 y Format1. As in x 8!:0 y , but y has rank at most 2 and each formatted column is in a box.
 
[x] 8!:2 y Format2. As in x 8!:0 y , but y has rank at most 2 and the result is a literal table.



The ranks of 8!:n are infinite. x 8!:n y formats array y according to format phrases x .

y is usually an array of real numbers. y may also be a literal array; in that case x is ignored and the result is <@,"1 y (with further processing depending on the variant of format). Finally, y may be a boxed array where each opened atom is a real number or a string, whence each opened atom is independently formatted.

x is a string of phrases separated by commas or an atom or list of phrases individually boxed. There is either a single phrase (applying to all columns) or one phrase per column. An elided x is equivalent to a:$~(_1+#$y)}.$y . That is, 8!:n y is equivalent to computing the number of decimal places independently for each column and using the minimum width for each number.

A format phrase consists of zero or more modifiers followed by an optional w.d , which specifies the width and the number of decimal places. w may be 0, and w. or w.d itelf may be omitted. The meanings in each case are as follows:

       width    decimal places
w.d w  d
0.d computed  d
d minimum  d
omitted minimum   computed

A specified or computed w applies to the entire set, whereas a minimum w applies to each number. An insufficient width gives a result of *s.

d is at most 9. A computed d applies to the entire set, and in that case exponential notation is used for non-zero numbers with magnitude less than 1e_9 or greater than 2e9 .

The modifiers are as follows. A modifier may be used at most once in a format phrase.

c     insert a comma between triplets of digits left of the decimal point
l  left justify (w must be specified or computed)
b<xx>  replacement for formatted zero
d<xx>  replacement for _ __ _. ; absent the d modifier _ __ _. are shown as is
m<xx>  prefix for negative formatted numbers, replacing the minus sign -
n<xx>  suffix for negative formatted numbers, replacing the minus sign -
p<xx>  prefix for non-negative formatted numbers
q<xx>  suffix for non-negative formatted numbers
r<xx>  background text, replicated cyclically as in the dyad $
s<xx>   xx is an even number of chars (default,substitute) providing substitutes for defaults
valid first chars are: e,.-*
the minus sign is - (instead of _ ) by default

The <xx> may be omitted and means <> . For example, b by itself means blank out formatted zeros. (xx) or [xx] or {xx} may be used instead of <xx>.

Examples:

   fmt =: 8!:0
   fmt1=: 8!:1
   fmt2=: 8!:2

   ] y=: 1.23 12345 123.4 0.12 ,__ 0 1.15 _1234.5,: _44 0.5 _0.5 0.1
1.23 12345 123.4    0.12
  __     0  1.15 _1234.5
 _44   0.5  _0.5     0.1

   '' fmt y            NB. minimum w and computed d, applying to all columns
+------+--------+------+--------+
|1.23  |12345.00|123.40|0.12    |
+------+--------+------+--------+
|__    |0.00    |1.15  |-1234.50|
+------+--------+------+--------+
|-44.00|0.50    |-0.50 |0.10    |
+------+--------+------+--------+
   $ '' fmt y
3 4
   #&> '' fmt y
4 8 6 4
2 4 4 8
6 4 5 4

   ',,,' fmt y         NB. minimum w and computed d individually for each column
+------+-------+------+--------+
|1.23  |12345.0|123.40|0.12    |
+------+-------+------+--------+
|__    |0.0    |1.15  |-1234.50|
+------+-------+------+--------+
|-44.00|0.5    |-0.50 |0.10    |
+------+-------+------+--------+
   ((4$<'') fmt y) -: ',,,' fmt y
1
   (fmt y) -: ',,,' fmt y
1

   '0.2' fmt y         NB. computed w, 2 decimal places, apply to all columns
+--------+--------+--------+--------+
|    1.23|12345.00|  123.40|    0.12|
+--------+--------+--------+--------+
|      __|    0.00|    1.15|-1234.50|
+--------+--------+--------+--------+
|  -44.00|    0.50|   -0.50|    0.10|
+--------+--------+--------+--------+
   (4$<'0.2') fmt y    NB. computed w, 2 decimal places, individually for each column
+------+--------+------+--------+
|  1.23|12345.00|123.40|    0.12|
+------+--------+------+--------+
|    __|    0.00|  1.15|-1234.50|
+------+--------+------+--------+
|-44.00|    0.50| -0.50|    0.10|
+------+--------+------+--------+

   NB. using various modifers
   (4$<'m<(>n<)>q< >0.2') fmt y
+-------+---------+-------+---------+
|  1.23 |12345.00 |123.40 |    0.12 |
+-------+---------+-------+---------+
|     __|    0.00 |  1.15 |(1234.50)|
+-------+---------+-------+---------+
|(44.00)|    0.50 | (0.50)|    0.10 |
+-------+---------+-------+---------+
   (4$<'cs<, .,>b<nil>d<n/a>0.2') fmt y
+------+---------+------+---------+
|  1,23|12 345,00|123,40|     0,12|
+------+---------+------+---------+
|   n/a|      nil|  1,15|-1 234,50|
+------+---------+------+---------+
|-44,00|     0,50| -0,50|     0,10|
+------+---------+------+---------+

   NB. fmt1 and fmt2
   'b<nil>d<n/a>0.2' fmt1 y
+--------+--------+--------+--------+
|    1.23|12345.00|  123.40|    0.12|
|     n/a|     nil|    1.15|-1234.50|
|  -44.00|    0.50|   -0.50|    0.10|
+--------+--------+--------+--------+
   'b<nil>d<n/a>c11.2' fmt2 y
       1.23  12,345.00     123.40       0.12
        n/a        nil       1.15  -1,234.50
     -44.00       0.50      -0.50       0.10


>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary