Roger, Robert, Nollaig,
Power Set! So THAT's what it is called! My Electrical Engineering math
courses in the '60s stopped at calculus and matrix algebra, and barely
touched on set theory, so I never knew that all the subsets of a set
had a name.
In any case, I don't need the function to include the null set or the
universal set, so Nollaig's function looks like it would be what I
want.
psm =. ((] # 2:) #: >:@i.@(_2: + 2: ^ ])) #L:0"1 <@i.
psmm=: (psm @#){ L:0 <@]
psmm 1 2 2 3 3
┌─┬─┬───┬─┬───┬───┬─────┬─┬───┬───┬─────┬───┬─────┬─────┬───────┬─┬───┬───┬─────┬───┬─────┬─────┬───────┬───┬─────┬─────┬───────┬─────┬───────┬───────┐
│3│3│3 3│2│2 3│2 3│2 3 3│2│2 3│2 3│2 3 3│2 2│2 2 3│2 2 3│2 2 3 3│1│1
3│1 3│1 3 3│1 2│1 2 3│1 2 3│1 2 3 3│1 2│1 2 3│1 2 3│1 2 3 3│1 2 2│1 2
2 3│1 2 2 3│
└─┴─┴───┴─┴───┴───┴─────┴─┴───┴───┴─────┴───┴─────┴─────┴───────┴─┴───┴───┴─────┴───┴─────┴─────┴───────┴───┴─────┴─────┴───────┴─────┴───────┴───────┘
Looks right!
Now how to I find the products of each subset?
prod psmm 1 2 2 3 3
3 3 9 2 6 6 18 2 6 6 18 4 12 .......
Skip
Skip Cave
Cave Consulting LLC
On Sun, May 8, 2016 at 12:35 AM, Nollaig MacKenzie
<[email protected]> wrote:
> My terminal has garbled much of the output, so I
> drop the previous content.
>
> I use
>
> psmn
> ((] # 2:) #: >:@i.@(_2: + 2: ^ ])) #L:0"1 <@i.
>
> which gives the power set without the null set
> and the relative universal set.
>
> Then psmm=: (psm @#){ L:0 <@]
>
> would give what SC wanted (except for the null
> and universal).
>
> Wouldn't be fast, I think.
>
> On 2016.05.08 00:18:40, you,
> the extraordinary Skip Cave, spake thus:
>
>> Nice! However, I realized that I didn't specify my problem in quite
>> enough detail. I need to keep duplicated integers in the final
>> sub-sets:
>
> --
> Nollaig MacKenzie
> ftp://ftp.nollaig.ca/pub/pap/
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm