Mathematica Asked by Topologica on April 13, 2021
I’m trying to generate a list of all possible unions of some sets to generate a topological space from a given basic sets.
For ex: Given
{1}, {2}, {4}, {1,3}
I should get
{{}, {1}, {2}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {1, 2, 3, 4}}
I found the following interesting post
But it includes intersection of sets as well.
sets = {{1}, {2}, {4}, {1, 3}};
Union[Union @@@ Subsets[sets]]
(* {{}, {1}, {2}, {4}, {1, 2}, {1, 3}, {1, 4}, {2, 4},
{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {1, 2, 3, 4}} *)
Correct answer by Roman on April 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP