46.6 Combinations

Combinations( mset )
Combinations( mset, k )

NrCombinations( mset )
NrCombinations( mset, k )

In the first form Combinations returns the set of all combinations of the multiset mset. In the second form Combinations returns the set of all combinations of the multiset mset with k elements.

In the first form NrCombinations returns the number of combinations of the multiset mset. In the second form NrCombinations returns the number of combinations of the multiset mset with k elements.

A combination of mset is an unordered selection without repetitions and is represented by a sorted sublist of mset. If mset is a proper set, there are {|mset| choose k} (see Binomial) combinations with k elements, and the set of all combinations is just the powerset of mset, which contains all subsets of mset and has cardinality 2^{|mset|}.

    gap> Combinations( [1,2,2,3] );
    [ [  ], [ 1 ], [ 1, 2 ], [ 1, 2, 2 ], [ 1, 2, 2, 3 ], [ 1, 2, 3 ],
      [ 1, 3 ], [ 2 ], [ 2, 2 ], [ 2, 2, 3 ], [ 2, 3 ], [ 3 ] ]
    gap> NrCombinations( [1..52], 5 );
    2598960    # number of different hands in a game of poker 

The function Arrangements (see Arrangements) computes ordered selections without repetitions, UnorderedTuples (see UnorderedTuples) computes unordered selections with repetitions and Tuples (see Tuples) computes ordered selections with repetitions.

Previous Up Top Next
Index

GAP 3.4.4
April 1997