Is there a command in GAP to find all n-subsets of a list? So the input is a list and the output should be a list, which gives all n-subsets of the list in the input. Here an example of a list with 3 elements and wanting to find all sublists with 2 elements:
Input:
L:=[ <[ 1, 0 ]>, <[ 1, 1 ]>, <[ 0, 1 ]> ]
Output:
[ [ <[ 1, 0 ]>, <[ 1, 1 ]> ], [ <[ 1, 0 ]>, <[ 0, 1 ]> ],
[ <[ 1, 1 ]>, <[ 0, 1 ]> ] ]
Here the error I get when using the combinations command:
gap> L;
[ <[ 1, 0 ]>, <[ 1, 1 ]>, <[ 0, 1 ]> ]
gap> Combinations(L,2);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `<' on 2 arguments called from
Sort( mset ); at /home/rene/Schreibtisch/gap4r8/lib/combinat.gi:235 called from
<function "Combinations">( <arguments> )
called from read-eval loop at line 157 of *stdin*
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
You can use combinations as documented in this chapter.
For example:
Generating the list of all combinations may be expensive, but you can iterate over them instead:
Also, you can form combinations of indices instead of combinations of elements of the set itself, for example: