FUNCTION: ListCompo - list of compositions of a given weight
CALLING SEQUENCE:
- ListCompo(n)
- COMP[ListCompo](n)
-
PARAMETERS:
- n = any non negative integer
SYNOPSIS:
- The ListCompo function gives all compositions of n. A composition of n
is list of positive integers, called parts, with sum n.
- When called with one argument, say n, the function returns the list of
all compositions of n.
- The following options are available:
- 'lg'=l sets the number of parts of each composition.
- 'lg'<=l sets the maximal number of parts of each
composition.
- 'maxouter'=p sets the outermost possible shape of the
diagram (composition with possible zeros).
- 'allowzeros' compositions may include zeros.
- 'nb' returns the number of compositions instead
of the list thereof.
- Given a composition comp, convert(comp, `+`) gives its weight.
- Whenever there is a conflict between the function name ListCompo and
another name used in the same session, use the long form
COMP['ListCompo'].
EXAMPLES:
> with(COMP):
> ListCompo(3);
[[3], [2, 1], [1, 2], [1, 1, 1]]
> ListCompo(2, 'allowzeros', 'lg'=3);
[[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]]
> ListCompo(5, 'maxouter'=[1,0,3], 'allowzeros', 'lg'<=4);
[[1, 0, 3, 1], [1, 0, 2, 2], [1, 0, 1, 3], [1, 0, 0, 4], [0, 0, 3, 2],
[0, 0, 2, 3], [0, 0, 1, 4], [0, 0, 0, 5]]
> ListCompo(20, 'lg'<=10, 'nb');
262144
SEE ALSO: ListCompoFatter ListCompoFiner