From: Harry Ohlsen Date: 2001-05-27T11:10:05+09:00 Subject: [ruby-talk:15783] Re: Subsets of a set Harry Ohlsen wrote: > I know that the Array class has a number of methods that make it usable > for storing sets. > > What I need is a method that will allow me to generate all of the > subsets of a given set > that are a certain size. By the way, I'd be happy to accept a routine which returns the set of ALL subsets (ie, the power set), because I could easily code something to extract elements of a given size from that. At least, that would be fine for sets of a reasonable size, since I actually want to generate them all, just grouped into sets of the various possible sizes. For any mathematicians out there, what I'm working on is something to generate all of the discrete topologies for a given set. Someone here recently did it in C++, but their code runs for a very long time and I'd like to see if I can write something neater in Ruby. Also, I want to extend it to the generation of Hasse diagrams for the topologies.