Here's an explicit version.

p=: 13 :'|:(i.!y)A.i.y'
   p 4
0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3
1 1 2 2 3 3 0 0 2 2 3 3 0 0 1 1 3 3 0 0 1 1 2 2
2 3 1 3 1 2 2 3 0 3 0 2 1 3 0 3 0 1 1 2 0 2 0 1
3 2 3 1 2 1 3 2 3 0 2 0 3 1 3 0 1 0 2 1 2 0 1 0
   
   p
[: |: (i. (A.~) ([: i. !))
   
How do you want to box the results?

Linda

-----Original Message-----
From: Programming <programming-boun...@forums.jsoftware.com> On Behalf Of Ric 
Sherlock
Sent: Wednesday, December 5, 2018 9:46 PM
To: Programming JForum <programm...@jsoftware.com>
Subject: Re: [Jprogramming] Boxed indices

or:
1 2 3 4 (1 3 5 7 {~ perm)each 4

On Thu, Dec 6, 2018 at 3:06 PM Henry Rich <henryhr...@gmail.com> wrote:

> (1 2 3 4 perm each 4) { each <1 3 5 7
>
> Untested.  Or,
>
> 1 2&p.&.> 1 2 3 4 perm each 4
>
> Also untested.
>
> Henry Rich
>
> On 12/5/2018 8:45 PM, Skip Cave wrote:
> > I want to generate all the 1, 2, 3, & 4 permutations of 4 items.
> > I can generate the indices:
> >
> > (1 2 3 4 perm each 4)
> >
> > ┌─┬───┬─────┬───────┐
> >
> > │0│0 1│0 1 2│0 1 2 3│
> >
> > │1│1 0│0 2 1│0 1 3 2│
> >
> > │2│0 2│1 0 2│0 2 1 3│
> >
> > │3│2 0│1 2 0│0 2 3 1│
> >
> > │ │0 3│2 0 1│0 3 1 2│
> >
> > │ │3 0│2 1 0│0 3 2 1│
> >
> > │ │1 2│0 1 3│1 0 2 3│
> >
> > │ │2 1│0 3 1│1 0 3 2│
> >
> > │ │1 3│1 0 3│1 2 0 3│
> >
> > │ │3 1│1 3 0│1 2 3 0│
> >
> > │ │2 3│3 0 1│1 3 0 2│
> >
> > │ │3 2│3 1 0│1 3 2 0│
> >
> > │ │ │0 2 3│2 0 1 3│
> >
> > │ │ │0 3 2│2 0 3 1│
> >
> > │ │ │2 0 3│2 1 0 3│
> >
> > │ │ │2 3 0│2 1 3 0│
> >
> > │ │ │3 0 2│2 3 0 1│
> >
> > │ │ │3 2 0│2 3 1 0│
> >
> > │ │ │1 2 3│3 0 1 2│
> >
> > │ │ │1 3 2│3 0 2 1│
> >
> > │ │ │2 1 3│3 1 0 2│
> >
> > │ │ │2 3 1│3 1 2 0│
> >
> > │ │ │3 1 2│3 2 0 1│
> >
> > │ │ │3 2 1│3 2 1 0│
> >
> > └─┴───┴─────┴───────┘
> >
> > How can I apply those indices to a 4-element vector consisting of 
> > the integers 1 3 5 7, in order to generate all the 1, 2, 3, & 4 
> > permutations
> of
> > those 4 integers?
> >
> > (1 2 3 4 perm each 4) each {1 3 5 7
> >
> > |domain error: each
> >
> > | (1 2 3 4 perm each 4) each{1 3 5 7
> >
> >
> > Fail!
> >
> >
> > Skip
> > --------------------------------------------------------------------
> > -- For information about J forums see 
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
> > .jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C9a50a5d4d490412e81
> > 0508d65b250482%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63679661
> > 1877403322&amp;sdata=ET6eWyFWxW5DT8Naas%2B7i5hmIlwsA0TZkJvJ%2FCPbgbE
> > %3D&amp;reserved=0
>
>
> ---
> This email has been checked for viruses by AVG.
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> avg.com&amp;data=02%7C01%7C%7C9a50a5d4d490412e810508d65b250482%7C84df9
> e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796611877403322&amp;sdata=d%2
> BoWC6hfiJicazkhDNPU1OX%2FJc0Kquibi29vdOnt%2Bto%3D&amp;reserved=0
>
> ----------------------------------------------------------------------
> For information about J forums see 
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.j
> software.com%2Fforums.htm&amp;data=02%7C01%7C%7C9a50a5d4d490412e810508
> d65b250482%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63679661187740
> 3322&amp;sdata=ET6eWyFWxW5DT8Naas%2B7i5hmIlwsA0TZkJvJ%2FCPbgbE%3D&amp;
> reserved=0
----------------------------------------------------------------------
For information about J forums see 
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C9a50a5d4d490412e810508d65b250482%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796611877403322&amp;sdata=ET6eWyFWxW5DT8Naas%2B7i5hmIlwsA0TZkJvJ%2FCPbgbE%3D&amp;reserved=0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to