Also this way… just using the concise notation for your own expressions… By 
using (!. Each) with the rank operator ...

   m |.each "1 0 n
┌─────────┬─────────┬─────────┬─────────┬─────────┐
│1 2 3 │2 3 1 │3 1 2 │1 2 3 │2 3 1 │
├─────────┼─────────┼─────────┼─────────┼─────────┤
│4 5 6 7 8│5 6 7 8 4│6 7 8 4 5│7 8 4 5 6│8 4 5 6 7│
├─────────┼─────────┼─────────┼─────────┼─────────┤
│8 6 │6 8 │8 6 │6 8 │8 6 │
├─────────┼─────────┼─────────┼─────────┼─────────┤
│3 5 7 9 │5 7 9 3 │7 9 3 5 │9 3 5 7 │3 5 7 9 │
└─────────┴─────────┴─────────┴─────────┴─────────┘
   ~.,m |.each "1 0 n
┌─────┬─────┬─────┬─────────┬─────────┬─────────┬─────────┬─────────┬───┬───┬───────┬───────┬───────┬───────┐
│1 2 3│2 3 1│3 1 2│4 5 6 7 8│5 6 7 8 4│6 7 8 4 5│7 8 4 5 6│8 4 5 6 7│8 6│6 8│3 
5 7 9│5 7 9 3│7 9 3 5│9 3 5 7│
└─────┴─────┴─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───┴───┴───────┴───────┴───────┴───────┘

> On 31 Oct 2020, at 5:58 pm, Skip Cave <[email protected]> wrote:
> 
> Wow! That will take me some studying to understand, but that is exactly
> what I needed. Thanks so much!
> 
> Skip
> 
> 
> Skip Cave
> Cave Consulting LLC
> 
> 
> On Sat, Oct 31, 2020 at 1:33 AM ethiejiesa via Programming <
> [email protected]> wrote:
> 
>> What about something like this?
>> 
>>       (|.~ ,.@i.@#)&.> n
>>    ┌─────┬─────────┬───┬───────┐
>>    │1 2 3│4 5 6 7 8│8 6│3 5 7 9│
>>    │2 3 1│5 6 7 8 4│6 8│5 7 9 3│
>>    │3 1 2│6 7 8 4 5│   │7 9 3 5│
>>    │     │7 8 4 5 6│   │9 3 5 7│
>>    │     │8 4 5 6 7│   │       │
>>    └─────┴─────────┴───┴───────┘
>> 
>> Skip Cave <[email protected]> wrote:
>>> Is there a more concise way to express m rotations of each of a set of
>>> items?
>>> 
>>> ]n=.1 2 3;4 5 6 7 8;8 6;3 5 7 9
>>> 
>>> ┌─────┬─────────┬───┬───────┐
>>> 
>>> │1 2 3│4 5 6 7 8│8 6│3 5 7 9│
>>> 
>>> └─────┴─────────┴───┴───────┘
>>> 
>>> m=. 0, 1, 2, 3, 4 NB. Number of rotations
>>> 
>>> ea =. each
>>> 
>>> 
>>> n,.(1|.ea n),.(2|.ea n),.(3|.ea n),.(4|.ea n)
>>> 
>>> ┌─────────┬─────────┬─────────┬─────────┬─────────┐
>>> 
>>> │1 2 3 │2 3 1 │3 1 2 │1 2 3 │2 3 1 │
>>> 
>>> ├─────────┼─────────┼─────────┼─────────┼─────────┤
>>> 
>>> │4 5 6 7 8│5 6 7 8 4│6 7 8 4 5│7 8 4 5 6│8 4 5 6 7│
>>> 
>>> ├─────────┼─────────┼─────────┼─────────┼─────────┤
>>> 
>>> │8 6 │6 8 │8 6 │6 8 │8 6 │
>>> 
>>> ├─────────┼─────────┼─────────┼─────────┼─────────┤
>>> 
>>> │3 5 7 9 │5 7 9 3 │7 9 3 5 │9 3 5 7 │3 5 7 9 │
>>> 
>>> └─────────┴─────────┴─────────┴─────────┴─────────┘
>>> 
>>> 
>>> Or better yet with no duplicated rotations::
>>> 
>>> 2 7$~.,n,.(1|.ea n),.(2|.ea n),.(3|.ea n),.(4|.ea n)
>>> 
>>> ┌─────────┬─────┬─────┬─────────┬─────────┬─────────┬─────────┐
>>> 
>>> │1 2 3 │2 3 1│3 1 2│4 5 6 7 8│5 6 7 8 4│6 7 8 4 5│7 8 4 5 6│
>>> 
>>> ├─────────┼─────┼─────┼─────────┼─────────┼─────────┼─────────┤
>>> 
>>> │8 4 5 6 7│8 6 │6 8 │3 5 7 9 │5 7 9 3 │7 9 3 5 │9 3 5 7 │
>>> 
>>> └─────────┴─────┴─────┴─────────┴─────────┴─────────┴─────────┘
>>> 
>>> Can this be done using iteration rather than explicitly listing each
>>> rotation?
>>> 
>>> Skip Cave
>>> Cave Consulting LLC
>>> ----------------------------------------------------------------------
>>> 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

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

Reply via email to