[Previous] [Next] [Contents]

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

## `combinat::composition` -- k-composition of an integer (deprecated)

#### Introduction

`combinat::composition` computes a list of all distinct ordered k-tuples (k_1, ..., k_n) such that n_1 + ... + n_k = n and n_i >= 1, i=1..k.

#### Call(s)

`combinat::composition(n,k)`

#### Parameters

`n, k` | - | integer

#### Returns

A list of type `DOM_LIST` containing every computed k-tuple also as a list of type `DOM_LIST`. If there exist no k-tuple the empty list is returned.

#### Details

- `combinat::composition``(n, k)` returns an empty list if n<1 or k<1 or n<k.

#### Example 1

How can one write 5 as a sum of two other positive integers?

    >> combinat::warnDeprecated(FALSE):
       combinat::composition(5,2)

                         [[1, 4], [2, 3], [3, 2], [4, 1]]

The function `combinat::composition` is deprecated:

    >> old_val:=combinat::warnDeprecated(TRUE):
       combinat::composition(5,2);
       combinat::warnDeprecated(old_val):

          Warning: combinat::composition(n,k) is obsolete.
          Please use 'combinat::integerVector::list(n,k, MinPart=1)' ins\
          tead. [combinat::composition]

                         [[1, 4], [2, 3], [3, 2], [4, 1]]

Here is the recommended replacement:

    >> combinat::integerVectors::list(5,2, MinPart=1)

                         [[4, 1], [3, 2], [2, 3], [1, 4]]

Note that the order is changed.

#### Example 2

There is no way to write 2 as the sum of 5 positive integers:

    >> combinat::composition(2,5)

                                        []

Here is the recommended replacement:

    >> combinat::integerVectors::list(2,5, MinPart=1)

                                        []

#### Example 3

`combinat::composition` does not handle symbolic expressions.

    >> combinat::composition(xx,2)

          Error: Wrong type of 1. argument (type 'Type::NonNegInt' expec\
          ted,
                 got argument 'xx');
          during evaluation of 'combinat::composition'

[Previous] [Next] [Contents]

MuPAD Combinat, an open source algebraic combinatorics package