Dear J Forum:
 
I've encounted one "bug" in the Boxing solution.  First, I adapted the code
of Devon McCormick:
 
(i.10) (4  : '(,y~:0) expand x<;.1~;y{. each 1') (0 1 2 0 3 4 0)
-T-T---TT-----T-------T┐
││0│1 2││3 4 5│6 7 8 9││
L+-+---++-----+-------+-
 
Everything is fine so far.  (I added the comma before "y~:0" because expand
doesn't like an atomic left argument.)  Notice that the 0-partitions are
boxed.  But when X is empty and the partition is all zeroes, the result is:
 
(i.0) (4  : '(,y~:0) expand x<;.1~;y{. each 1') 0 0 0
0 0 0
 
I would like it in this case to be three empty boxes.  Can I make the expand
operator fill with empty boxes?
 
I will get the desired outcome with "(a:) (4  : '(,y~:0) expand x<;.1~;y{.
each 1') 0 0 0"  So my function must treat an empty left argument as an ace.
This goes back to last week's discussion on the difference between a: and
i.0. 
 
Sincerely,
 
Leigh
 
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Devon McCormick
Sent: Tuesday, October 31, 2006 11:52 PM
To: Programming forum
Subject: Re: [Jprogramming] Boxing according to a Pattern
 
NB. Fairly similar to Boss's solution:
   X=. i.10
   P=. 1 2 0 3 0 4
   ;P{.&.>1           NB. Build basic partition vec,
1 1 0 1 0 0 1 0 0 0   NB.  ignoring empties for now.
   $;P{.&.>1         NB. Correct length
10
   X<;.1~;P{.&.>1     NB. OK, now put empties into this
+-+---+-----+-------+
|0|1 2|3 4 5|6 7 8 9|
+-+---+-----+-------+
   (P~:0)exp X<;.1~;P{.&.>1
+-+---++-----++-------+
|0|1 2||3 4 5||6 7 8 9|
+-+---++-----++-------+
   exp
#^:_1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to