% $Date: 2004/10/04 17:25:12 $ $Author: nthiery $ $Revision: 1.1.1.2 $

\begin{Mhelppage}{ListCompo}{V. Prosper}%
  \begin{MInfo}
    \eng{list of compositions of a given weight}
  \end{MInfo}
  
  \MDeclareOption{\length}{lg}
  \MDeclareOption{\maxouter}{maxouter}
  \MDeclareOption{\allowzeros}{allowzeros}
  \MDeclareOption{\nb}{nb}

  \begin{MCalls}
    \Mcall{n \Mopt{,options}}
  \end{MCalls}

  \begin{MParameters}
    \param{n}
    \eng{any non negative integer}
  \end{MParameters}
  \begin{MOptions}
    \option{\length=l, \length<=l}
    \eng{(maximal) number of parts of each composition}
    \option{\maxouter=p}
    \eng{outermost possible shape of the diagram}
    \option{\allowzeros}
    \eng{compositions may include zeros}
    \option{\nb}
    \eng{only counts objects}
  \end{MOptions}
  
  \Mwarning{Use the syntax \Mex{hold(identifier)}, instead of
    \Mex{identifier}, if one of the identifiers above is already
    defined. }

  \begin{MIntro}
    \eng{The {\Mthis} function gives all compositions of \Mex{n}.  A
      composition of \Mex{n} is a list of positive integers, called
      parts, with sum \Mex{n}.
      
      When called with one argument, say \Mex{n}, the function returns
      the list of all compositions of n.
      
      Given a composition \Mex{comp}, \Mex{\_plus(op(comp))} gives its
      weight.}
  \end{MIntro}

\begin{MExample}{ex1}
\begin{Mexin}
muEC::COMP::ListCompo( 3 );
\end{Mexin}
\begin{Mexout}
               [[3], [2, 1], [1, 2], [1, 1, 1]]
\end{Mexout}
%
\begin{Mexin}
muEC::COMP::ListCompo( 2, allowzeros, lg=3 );
\end{Mexin}
\begin{Mexout}
[[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1],

   [0, 0, 2]]
\end{Mexout}
%
\begin{Mexin}
muEC::COMP::ListCompo( 5, maxouter=[4,3], allowzeros, lg<=4 );
\end{Mexin}
\begin{Mexout}
[[4, 1], [4, 1, 0], [4, 1, 0, 0], [4, 0, 1], [4, 0, 1, 0],

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

   [3, 1, 1, 0], [3, 1, 0, 1], [3, 0, 2], [3, 0, 2, 0],

   [3, 0, 1, 1], [3, 0, 0, 2], [2, 3], [2, 3, 0],

   [2, 3, 0, 0], [2, 2, 1], [2, 2, 1, 0], [2, 2, 0, 1],

   [2, 1, 2], [2, 1, 2, 0], [2, 1, 1, 1], [2, 1, 0, 2],

   [2, 0, 3], [2, 0, 3, 0], [2, 0, 2, 1], [2, 0, 1, 2],

   [2, 0, 0, 3], [1, 3, 1], [1, 3, 1, 0], [1, 3, 0, 1],

   [1, 2, 2], [1, 2, 2, 0], [1, 2, 1, 1], [1, 2, 0, 2],

   [1, 1, 3], [1, 1, 3, 0], [1, 1, 2, 1], [1, 1, 1, 2],

   [1, 1, 0, 3], [1, 0, 4], [1, 0, 4, 0], [1, 0, 3, 1],

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

   [0, 3, 0, 2], [0, 2, 2, 1], [0, 2, 1, 2], [0, 2, 0, 3],

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

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

   [0, 0, 0, 5]]
\end{Mexout}
%
\begin{Mexin}
muEC::COMP::ListCompo( 20, lg<=10, nb );
\end{Mexin}
\begin{Mexout}
                            262144
\end{Mexout}
\end{MExample}

\MRelatedFunctions{ListCompoFatter,ListCompoFiner,TYP::IsCompo}
\end{Mhelppage}
