Who needs boxes? :)

   i.4 4
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
   8$"1]8$i.4 4
 0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7
 8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15
 0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7
 8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15

A rank-polymorphic solution derives (though unfortunately it requires explicit code):

   f=. ] ]F.:{{({.x) $"({:x) y}} (*$) ,. |.@:>:@i.@$@$@]
   2 3 f i.4 4
 0  1  2  3  0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7  4  5  6  7
 8  9 10 11  8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15 12 13 14 15
 0  1  2  3  0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7  4  5  6  7
 8  9 10 11  8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15 12 13 14 15
   2 2 2 f i.2 2 2
0 1 0 1
2 3 2 3
0 1 0 1
2 3 2 3

4 5 4 5
6 7 6 7
4 5 4 5
6 7 6 7

0 1 0 1
2 3 2 3
0 1 0 1
2 3 2 3

4 5 4 5
6 7 6 7
4 5 4 5
6 7 6 7


On Fri, 1 Jul 2022, Thomas McGuire wrote:

I was playing with the Window driver and trying to paint the toucan.bmp to the window I created. Expanding on that I wanted to pain a panel of toucan.bmp bitmaps to the background. Now I was able to glom together the bitmaps into a 2 x 2 panel of bitmaps, but it seems I should be able to just specify how many rows and columns of matrices I want and let J handle the complexity.

I can assign demensions easily and get the structure of what I want through boxing. For this I will use a simple square matrix:
  i. 4 4
0  1  2  3
4  5  6  7
8  9 10 11
12 13 14 15

If I box this I can dial up any table of boxes using shape:

   <i. 4 4
┌───────────┐
│ 0  1  2  3│
│ 4  5  6  7│
│ 8  9 10 11│
│12 13 14 15│
└───────────┘

Then using shape you get:

   2 2$<i.4 4
┌───────────┬───────────┐
│ 0  1  2  3│ 0  1  2  3│
│ 4  5  6  7│ 4  5  6  7│
│ 8  9 10 11│ 8  9 10 11│
│12 13 14 15│12 13 14 15│
├───────────┼───────────┤
│ 0  1  2  3│ 0  1  2  3│
│ 4  5  6  7│ 4  5  6  7│
│ 8  9 10 11│ 8  9 10 11│
│12 13 14 15│12 13 14 15│
└───────────┴───────────┘

I want those to squish together to form an 8x8 square matrix as it appears 
right now. I came up with the following: I raze the structure (with ‘;’) and 
then insert a splice (‘,.’) using the ‘/‘ adverb:

   ,./;"1(2 2$<i. 4 4)
0  1  2  3  0  1  2  3
4  5  6  7  4  5  6  7
8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15
0  1  2  3  0  1  2  3
4  5  6  7  4  5  6  7
8  9 10 11  8  9 10 11
12 13 14 15 12 13 14 15

This works with the only caveat that if you specify a rectangular matrix as the final form the final dimensions are the transpose of what you would expect (minor detail).
I am wondering is there a way to duplicate a seed matrix and give it the form I 
want without resorting to boxing. My previous attempts at this failed.

Also is there a way to unbox and have this retain its current structure? I failed 
at trying different ranks with raze (‘;’) and unbox (‘>’) and getting anything 
close to what I have now.

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

Reply via email to