[Previous] [Next] [Contents]

[ImplState=stable,TestState=stable,DocState=deprecated]

combinat::choose -- k-subsets of a given set (deprecated)

Introduction

combinat::choose(set,k) computes all k-subsets of the set set

combinat::choose(n,k) computes all k-subsets of the set 1,2,...,n.

Call(s)


combinat::choose(set,k)
combinat::choose(n,k)

Parameters

set- a set of domain type DOM_SET
k- a nonnegative integer
n- a nonnegative integer

Returns

combinat::choose returns an expression sequence, consisting of the computed subsets.

Example 1

Compute all the subsets of a,b,c,d,e containing 3 elements

>> combinat::warnDeprecated(FALSE):
   combinat::choose({a,b,c,d,e},3)
      {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e},
      
         {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}

The function combinat::choose is deprecated:

>> old_val:=combinat::warnDeprecated(TRUE):
   combinat::choose({a,b,c,d,e},3);
   combinat::warnDeprecated(old_val):
     
      Warning: combinat::choose(s,k) is obsolete.
      Please use 'combinat::subsets::list(s,k)' instead. [combinat::\
      choose]
      
      {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e},
      
         {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}
        

Here is the recommended replacement:

>> combinat::subsets::list({a,b,c,d,e},3)
     
      [{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e},
      
         {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}]
        

Note that the result is returned as a list.

Example 2

Compute all the subsets of 1,2,3 containing 2 elements

>> combinat::choose(3,2) 
     
                          {1, 2}, {1, 3}, {2, 3}
        

Here is the recommended replacement:

>> combinat::subsets::list(3,2)
     
                         [{1, 2}, {1, 3}, {2, 3}]
        

Example 3

It is not a good idea to compute the subsets containing -1 element

>> combinat::choose({a,3},-1) 
     
      Error: Wrong type of 2. argument (type 'Type::NonNegInt' expec\
      ted,
             got argument '-1');
      during evaluation of 'combinat::choose'
        

[Previous] [Next] [Contents]


MuPAD Combinat, an open source algebraic combinatorics package