Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have this two sets:

$A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$

$B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$

Now I want to list all possible elements that are in $B$. How do I do this?

share|improve this question
2  
Are you sure this is related to Mathematica and not to mathematics ? –  Sektor Oct 28 '13 at 7:56
2  
Pretty sure, since I want the program (Wolfram Mathematica, indeed) to list the possibilities for me ;) –  afpel Oct 28 '13 at 17:39
add comment

1 Answer

up vote 8 down vote accepted

If I'm not mistaken you can do this: (I will replace [EmptySet] with ES because I have troubles formatting it here)

a = { ES, {ES}, {{ES}, ES}};

b = {#, {#, #2}} & @@@ Tuples[a, {2}];
% // Column
{ES, {ES, ES}}
{ES, {ES, {ES}}}
{ES, {ES, {{ES}, ES}}}
{{ES}, {{ES}, ES}}
{{ES}, {{ES}, {ES}}}
{{ES}, {{ES}, {{ES}, ES}}}
{{{ES}, ES}, {{{ES}, ES}, ES}}
{{{ES}, ES}, {{{ES}, ES}, {ES}}}
{{{ES}, ES}, {{{ES}, ES}, {{ES}, ES}}}
}

Or even more clear way:

b2 = Table[{x, {x, y}}, {x, a}, {y, a}] // Flatten[#, 1] &;

b2 == b
True
share|improve this answer
    
Great, that's it! Many thanks! –  afpel Oct 29 '13 at 13:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.