Re: generating subsets
- To: mathgroup at smc.vnet.net
- Subject: [mg21599] Re: [mg21588] generating subsets
- From: Maris Tõnso <maris at tpu.ee>
- Date: Sun, 16 Jan 2000 22:43:47 -0500 (EST)
- References: <200001160856.DAA10812@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Michael,
I find the following function Subsets from Ilan Vardi's package
Miscellaneous`OneLiners`
Subsets[x_]:= Distribute[{{}, {#}}& /@ x, List, List, List, Union]
Regards
Maris Tonso
Michael Gass wrote:
> I need an _efficient_ procedure for generating all the subsets
> of a given set. The procedure should produce output as follows:
>
> subSets[{a,b,c}]
> produces
> {{}, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}
>
> I have written a recursive procedure to do this, but
> it takes quite a while to generate, say, the 512 subsets
> of a 9 element set and I need to work with somewhat larger
> sets.
>
> Thanks
>
> --
> Michael Gass Department of Mathematics
> phone: 320 363-3090 St. John's University
> email: mgass at csbsju.edu Collegeville, MN 56321-3000