[GAP Forum] subsets

Alexander Konovalov alexk at mcs.st-andrews.ac.uk
Wed Oct 24 15:38:56 BST 2012


On 24 Oct 2012, at 10:39, Stefan Kohl wrote:

> Dear Forum,
> 
> Abdulsatar Al-Juburie asked:
> 
>> Let X be a finite set and let x be a fixed element of X.
>> Is there any function in GAP that generates all subsets of X that contains x.
> 
> Provided that the set X is small enough such that the desired list
> of subsets fits into the memory of the computer, the following statement
> will do what you want:
> 
> List(Combinations(Difference(X,[x])),Y->Union(Y,[x]));

Additionally, if one needs to enumerate such subsets, but not necessarily 
keep all of them in the memory at the same time, then these two functions 
(which were introduced in GAP 4.5) may be useful:

* IteratorOfCombinations( mset[, k] )	
* EnumeratorOfCombinations( mset )

They may be helpful when the desired list of subsets is not fitting into 
the memory, but its enumeration is still feasible, or when one wants to 
enumerate them in parallel.

To see the documentation, enter `?IteratorOfCombinations' or
`?EnumeratorOfCombinations' in GAP.

Hope this helps,
Alexander


More information about the Forum mailing list