Alternatively,

  { i.&.> 2 3
┌───┬───┬───┐
│0 0│0 1│0 2│
├───┼───┼───┤
│1 0│1 1│1 2│
└───┴───┴───┘

   { i.&.> 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│
└─────┴─────┴─────┴─────┘



On Tue, Jan 10, 2017 at 3:11 PM, Ben Gorte - CITG <[email protected]>
wrote:

> How about:
>  4$.$. i.3 4
> 0 1
> 0 2
> 0 3
> 1 0
> 1 1
> 1 2
> 1 3
> 2 0
> 2 1
> 2 2
> 2 3
>    4$.$. i.2 3 4
> 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
>
> (thanks to Marshall Lochbaum iirc)
> Ben
> _______________________________________
> From: Programming [[email protected]] on behalf of
> Skip Cave [[email protected]]
> Sent: Wednesday, January 11, 2017 00:05
> To: [email protected]
> Subject: [Jprogramming] Indices of a matrix
>
> 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
> ----------------------------------------------------------------------
> 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