Bill Harris <[EMAIL PROTECTED]> wrote:

> But...
>
> Try this:
>
> ,----[ 29.ijs ]
> | a=: 'Line 1'; 10j2 ": 12345.67
> | a=: a,:'Line 2'; 10j2 ": 6543.21
> |
> | b=: 'Line 1'; 0j2 ": 12345.67
> | b=: b,:'Line 2'; 0j2 ": 6543.21
> `----
>
> ,----[ Fresh ijx session ]
> |   load 'c:\program files\j601\temp\29.ijs'
> |    a
> | +-----------------+
> | ¦Line 1¦  12345.67¦
> | +------+----------¦
> | ¦Line 2¦   6543.21¦
> | +-----------------+
> |    b
> | +---------------+
> | ¦Line 1¦12345.67¦
> | +------+--------¦
> | ¦Line 2¦6543.21 ¦
> | +---------------+
> |    9!:14''
> | j601/2006-11-17/17:05
> |   $ each a
> | +----+
> | ¦6¦10¦
> | +-+--¦
> | ¦6¦10¦
> | +----+
> |   $ each b
> | +---+
> | ¦6¦8¦
> | +-+-¦
> | ¦6¦7¦
> | +---+
> `----
>
> I almost I see what's going on, but I'm still confused.  6543.21 is
> right-justified in it's space.  As the DoJ says "enough space is
> allocated" and the number is only 7 wide, it's shoved up against the
> right of it's 7-character-wide space.  When I create B, ,: seems to
> extend the cell with 6543.21 by appending a space, which then messes up
> the right justification.

The rank conjunction in J (either invoked implicitly by " or
implicitly due to verbs of less than infinite rank) automatically
appens results together; results of unequal shape are expanded to
be the size of the maximum of the dimensions, and LEFT-jutified
within that space.

This is why J verbs that produce differently-shaped results
that need to be right-justified have infinite rank (so the verb
itself can perform the right justification), while other
verbs that produce results that need to be left-justified can
just be of lower rank and let the rank conjunction do all the
justification for them implicitly.

In your example b, you format the two numbers separately;
each one is right-justified within its own space, but the spaces
are of different lengths (since the numbers won't fit in 0
characters, so when they are appended, they are subsequently
left-justified. The only reason this doesn't happen with example
a is that both strings are coincidentally the same length.
What you need is for them to be right-justified SIMULTANEOUSLY.

These two behaviors can be more easiliy compared here:

   ('Line 1';'Line 2'),.<"1 [ 0j2 ": [ 123456.7,: 65432.1
+------+---------+
|Line 1|123456.70|
+------+---------+
|Line 2| 65432.10|
+------+---------+
   ('Line 1';'Line 2'),.<"1 [ 0j2 ":"0 [ 123456.7,: 65432.1
+------+---------+
|Line 1|123456.70|
+------+---------+
|Line 2|65432.10 |
+------+---------+

The first example is what you want to happen.
The second example is what you are actually doing.

-- Mark D. Niemiec <[EMAIL PROTECTED]>

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to