NB. Bill Lam fixed my overapplication of the stitch operator
   NB. that fixes the transpose issue I was having with my original 
   NB. Solution
   NB. my way:
    ,./;"1(3 2$<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

   NB. Bill’s way
   ,/ ,./&:>"1(3 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
 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

   NB. Bill’s way is more of how I would piece together a matrix given a set of 
rows by hand
   NB. and you can see Bill gets 3 rows of matrices by 2 columns of matrices as 
you would expect
   NB. if shape knew you were operating on whole matrices.

   NB. Raul Miller's solution
   NB. (,seed){~($seed)#.($seed)|"1 ($target)#:i.$target
   NB. in the above Raul only uses the dimensions of the target
   NB. so I created panelize that takes the target dimensions as a parameter

   panelize =: 4 : '(,y){~($y)#.($y)|"1 (x)#:i.x'
   10 10 panelize p:i.3 3
 2  3  5  2  3  5  2  3  5  2
 7 11 13  7 11 13  7 11 13  7
17 19 23 17 19 23 17 19 23 17
 2  3  5  2  3  5  2  3  5  2
 7 11 13  7 11 13  7 11 13  7
17 19 23 17 19 23 17 19 23 17
 2  3  5  2  3  5  2  3  5  2
 7 11 13  7 11 13  7 11 13  7
17 19 23 17 19 23 17 19 23 17
 2  3  5  2  3  5  2  3  5  2

   NB. this solution plays into a more general graphics issue that if a window 
repaints
   NB. I can grab the current window display size in pixels and create a 
background to paint it
   NB.
   NB. My original proposal was to create the window on a multiple of whole 
bitmap size
   NB. That didn't take into account resizing the window.

   NB. Here is the graphics code using Raul’s solution. No resizing in this I 
would need to 
   NB. implement a paint method for the ‘g’ child window
   
   b =: readimg_jqtide_ jpath '~addons/graphics/bmp/toucan.bmp’
   $b
 144 200

   c =: 500 625 panelize b
 
   wd 'pc mywin;pn ToucanWin'
   wd 'cc g isidraw'
   wd 'set g minwh ', ":(|.$c)
   wd 'pshow'
   glsel 'g'
0
   glpixels 0 0, (|. $c), ,c
0
   wd 'pshow'

   NB. Elijah’s is the simplest and now that I see it, how did I not run into 
it when I was 
   NB. playing with shape (‘$’) before I asked this question?
   NB. Elijah grows the rows and then the columns using shape. He also saves a 
keystroke by 
   NB. His use of return right (‘]’) since the rank specification on the second 
$ (’$”1’) will
   NB. run into the number parameter for the first $. I say saves a keystroke 
because I always 
   NB. use parenthesis to separate numbers out when they may get parsed as a 
vector

   NB. Here I create a function out Elijah’s method but I switch things by 
growing the columns first
   NB. then I grow the rows. I end up with a couple of different panelize 
functions from this.

    panelize1 =: {{(0{x)$(1{x)$"1 y}}
   10 12 panelize1 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
 0  1  2  3  0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7  4  5  6  7

   NB. by cheating and letting J figure out the tacit form I get a tacit for 
Elijah’s solution
   panelize2 =: 13 : '(0{x)$((1{x)$"1 y)'
   panelize2
(0 {  [) $ ] $"1~ 1 {  [

   panelize3 =: (0 {  [) $ ] $"1~ 1 {  [
   10 12 panelize3 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
 0  1  2  3  0  1  2  3  0  1  2  3
 4  5  6  7  4  5  6  7  4  5  6  7

NB. Pascal’s solution didn’t generalize for me very easily. I would need to 
calculate dimensions
NB. to get solutions. My brief experimenting shows that he gets to my 
intermediate solution
NB. without boxing and the need therefore to raze afterward and applies the ,./ 
to piece it together

Thanks to everyone for the replies

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

Reply via email to