[GAP Forum] disjoint pairs
Burkhard Höfling
burkhard at hoefling.name
Wed Nov 16 00:45:34 GMT 2011
On 2011-11-16, at 00:32 , Lisette Brillemans wrote:
> Hello everybody!
>
> Is there a function in GAP that returns all possible pairs of disjoint
> combinations of a (subset of a) list?
There isn't a single function, but you can easily build one. Essentially two nested for-loops. A short way to do this is
s := [1..5];
Concatenation (List (Combinations (s), t -> List (Combinations(Difference (s,t)), u -> [t, u])));
or, if you don't want to allow the empty set,
Concatenation (List (Filtered (Combinations (s), t -> not IsEmpty(t)), t -> List (Filtered (Combinations(Difference (s,t)), u -> not IsEmpty(u)), u -> [t, u])));
Cheers
Burkhard.
More information about the Forum
mailing list