Bill,
You're confusing the display of an array with the display of the individual
items of that array.
Each of your numbers is right-justified within its own format (the result of
its individual ": ), but the numbers are not right-justified with respect to
one another.
Since the first number is 8-wide, the second number would also have to be
8-wide to right justify "universally". But, since you requested the second
number only be "as wide as necessary" (for that specific number), its format is
only 7-wide.
Now, the total array has its own formatting rules. In the default
configuration of J, boxes LEFT-justify their contents; further, the edges of
boxes always line up. Since the first number is one wider than the second, and
the boxes left-justify their contents, and the right edges of the boxes must
line up, in the display of the array, a padding space was added at the end of
the shorter number. Of course, this does not affect the contents of the actual
box, only its display (though it would effect the result if you formatted the
entire array with ": ).
So, to get your numbers right-justified universally, you can do one of the
following:
(A) Make each number take a less parochial view, and format
itself with respect to the widest number in the set.
(B) Justify the numbers AFTER you format them.
(C) Change J's configuration to RIGHT-justify the contents
of boxes (remembering that this will right-justify
the display of EVERY box, not just the numbers you
intend.
For (A), either:
fmt =: 4&$: : (] ":"0~ ((+ j. [) 1 + 10 >[EMAIL PROTECTED] 1 >.
>./))
(L =: <;._1 '/Line 1/Line 2') ,. <"1] 2 fmt 12345.67 6543.21
+------+--------+
|Line 1|12345.67|
+------+--------+
|Line 2| 6543.21|
+------+--------+
or use 8!: :
L ,. '0.2' 8!:0] 12345.67 6543.21
+------+--------+
|Line 1|12345.67|
+------+--------+
|Line 2| 6543.21|
+------+--------+
For (B):
require 'strings'
L ,. <@rjust 0j2 ":"0] 12345.67 6543.21
For (C):
9!:17 ] 0 2
L ,. 0j2 <@":"0] 12345.67 6543.21
+------+--------+
|Line 1|12345.67|
+------+--------+
|Line 2| 6543.21|
+------+--------+
Hope this helps,
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm