Given a 3x4 matrix:


  a =. i. 3 4

  a

0 1  2  3

4 5  6  7

8 9 10 11



I can get the horizontal indices:



   4|a

0 1 2 3

0 1 2 3

0 1 2 3





How do I get the vertical indices?



  3?a   NB. The question-mark represents the unknown verb

0 0 0 0

1 1 1 1

2 2 2 2



Ultimately, I want to design a verb bix, that will take a list of
dimensions of any length, and generate boxed indices of the resulting
array. The number of integers in each box will be the same as the rank of
the array:




  bix 10

┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐

│0│1│2│3│4│5│6│7│8│9│

└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘



  bix 3 4

┌───┬───┬───┬───┐

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

├───┼───┼───┼───┤

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

├───┼───┼───┼───┤

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

└───┴───┴───┴───┘


  bix 2 3 4

┌─────┬─────┬─────┬─────┐

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

├─────┼─────┼─────┼─────┤

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

├─────┼─────┼─────┼─────┤

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

└─────┴─────┴─────┴─────┘

┌─────┬─────┬─────┬─────┐

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

├─────┼─────┼─────┼─────┤

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

├─────┼─────┼─────┼─────┤

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

└─────┴─────┴─────┴─────┘
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to