This was my take, don’t have time to check whether it duplicates/plagiarises 
others’ offerings.  Apologies for poor formatting from iPad.

allpermofallsize =: ;@(<<"1@:{~ each(perm ~ each >:@i.) @#)

   #allpermofallsize 1 3 5
15
   10 {. allpermofallsize 1 3 5
+-+-+-+---+---+---+---+---+---+-----+
|1|3|5|1 3|3 1|1 5|5 1|3 5|5 3|1 3 5|
+-+-+-+---+---+---+---+---+---+-----+

Cheers,

Mike


Please reply to [email protected].      
Sent from my iPad

> On 6 Dec 2018, at 15:35, David Lambert <[email protected]> wrote:
> 
>    |:  (A.~ i.@!@#)  'abcd'  NB. generate the permutationsdirectly
> aaaaaabbbbbbccccccdddddd
> bbccddaaccddaabbddaabbcc
> cdbdbccdadacbdadabbcacab
> dcdbcbdcdacadbdabacbcaba
> 
> 
>    NB. find the subsets within
>    ([: <@~.@|:\ [: |: (A.~ i.@!@#))  'abcd'
> ┌─┬──┬───┬────┐
> │a│ab│abc│abcd│
> │b│ac│abd│abdc│
> │c│ad│acb│acbd│
> │d│ba│acd│acdb│
> │ │bc│adb│adbc│
> │ │bd│adc│adcb│
> │ │ca│bac│bacd│
> │ │cb│bad│badc│
> │ │cd│bca│bcad│
> │ │da│bcd│bcda│
> │ │db│bda│bdac│
> │ │dc│bdc│bdca│
> │ │  │cab│cabd│
> │ │  │cad│cadb│
> │ │  │cba│cbad│
> │ │  │cbd│cbda│
> │ │  │cda│cdab│
> │ │  │cdb│cdba│
> │ │  │dab│dabc│
> │ │  │dac│dacb│
> │ │  │dba│dbac│
> │ │  │dbc│dbca│
> │ │  │dca│dcab│
> │ │  │dcb│dcba│
> └─┴──┴───┴────┘
> 
>> On 12/6/18 7:00 AM, [email protected] wrote:
>> Date: Wed, 5 Dec 2018 19:45:51 -0600
>> From: Skip Cave<[email protected]>
>> To:"[email protected]"  <[email protected]>
>> Subject: [Jprogramming] Boxed indices
>> Message-ID:
>>    <caj8lg_dqrajrtogrm0grouokjnjabvhvmguaoa3gd94w9u6...@mail.gmail.com>
>> Content-Type: text/plain; charset="UTF-8"
>> 
>> 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)
> ----------------------------------------------------------------------
> 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