From 9dbc25b4e44ce350c7bc495e01ef15fdc48d513a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 9 Sep 2009 23:55:47 +0000 Subject: coollist update (9sep09) git-svn-id: svn://tug.org/texlive/trunk@15194 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/latex/coollist/coollist.dtx | 413 +++++++++++++-------- 1 file changed, 248 insertions(+), 165 deletions(-) (limited to 'Master/texmf-dist/source/latex/coollist') diff --git a/Master/texmf-dist/source/latex/coollist/coollist.dtx b/Master/texmf-dist/source/latex/coollist/coollist.dtx index 2d86d834ef7..ddc9bb0ebdd 100644 --- a/Master/texmf-dist/source/latex/coollist/coollist.dtx +++ b/Master/texmf-dist/source/latex/coollist/coollist.dtx @@ -2,7 +2,7 @@ % %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{coollist} -% [2007/10/06 v1.2 COntent Oriented LaTeX Lists] +% [2007/10/14 v1.3 COntent Oriented LaTeX Lists] %\RequirePackage{ifthen} %\RequirePackage{amsmath} %\RequirePackage{amssymb} @@ -25,7 +25,7 @@ % \fi % % -% \CheckSum{211} +% \CheckSum{247} % % %% \CharacterTable @@ -125,8 +125,8 @@ % The default values are % % \begin{tabular}{ll} -% |listStop| & \makeatletter |@@| \makeatother \\ -% |listEnd| & \makeatletter |@@@| \makeatother +% |listStop| & \makeatletter |@@| \makeatother \\ +% |listEnd| & \makeatletter |@@@| \makeatother % \end{tabular} % % @@ -161,9 +161,17 @@ % % % +% \DescribeMacro{\listcopy} +% |\listcopy|\marg{listtocopy}\marg{listcopybase} stores the elements of \meta{listtocopy} into the list +% \meta{listtocopybase}. +% +% +% % \DescribeMacro{\listsum} -% |\listsum|\marg{list}\marg{macro} stores the sum of the comma delimited list \meta{list} in the macro -% \meta{macro}. Integers are recognized and summed accordingly. All other tokens are summed as variables with some +% |\listsum|\oarg{storedlist}\marg{list}\marg{macro} stores the sum of the comma delimited list \meta{list} +% (if \meta{storedlist} is |storedlist=false|) or the sum of the stored list with base name \meta{list} +% (if \meta{storedlist} is |storedlist=true|) in the macro \meta{macro}. +% Integers are recognized and summed accordingly. All other tokens are summed as variables with some % integer coefficient as the end result. % % @@ -183,9 +191,9 @@ % \DescribeMacro{\listval} % % \begin{tabular}{ll} -% |\listval{1,2,3,4}{0}| & \listval{1,2,3,4}{0} (the null string) \\ -% |$\listval{\alpha,\beta,\gamma}{2}$| & $\listval{\alpha,\beta,\gamma}{2}$ \\ -% |\listval{a,b,c}{4}| & \listval{a,b,c}{4} (the null string) +% |\listval{1,2,3,4}{0}| & \listval{1,2,3,4}{0} (the null string) \\ +% |$\listval{\alpha,\beta,\gamma}{2}$| & $\listval{\alpha,\beta,\gamma}{2}$ \\ +% |\listval{a,b,c}{4}| & \listval{a,b,c}{4} (the null string) % \end{tabular} % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -198,16 +206,16 @@ % % \begin{tabular}{ll} % |\liststore{1,2,3,4}{temp}| -% \\ -% |\tempi;\tempii;\tempiii;\tempiv| & \liststore{1,2,3,4}{temp} \tempi;\tempii;\tempiii;\tempiv -% \\[1cm] +% \\ +% |\tempi;\tempii;\tempiii;\tempiv| & \liststore{1,2,3,4}{temp} \tempi;\tempii;\tempiii;\tempiv +% \\[1cm] % |\liststore{a_1,a_2,a_3,a_4}{temp}| -% \\ -% |$\tempi;\tempii;\tempiii;\tempiv$| & \liststore{a_1,a_2,a_3,a_4}{temp} $\tempi;\tempii;\tempiii;\tempiv$ -% \\[1cm] +% \\ +% |$\tempi;\tempii;\tempiii;\tempiv$| & \liststore{a_1,a_2,a_3,a_4}{temp} $\tempi;\tempii;\tempiii;\tempiv$ +% \\[1cm] % |\liststore{a,b}{temp}| -% \\ -% |\tempi;\tempii| & \liststore{a,b,c}{temp} \tempi;\tempii +% \\ +% |\tempi;\tempii| & \liststore{a,b,c}{temp} \tempi;\tempii % \end{tabular} % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -219,10 +227,10 @@ % \DescribeMacro{\listlen} % % \begin{tabular}{ll} -% |\listlen{1,2,3,4,5}| & \listlen{1,2,3,4,5} \\ -% |\listlen{}| & \listlen{} \\ -% |\listlen{1,2}| & \listlen{1,2} \\ -% |\listlen{1}| & \listlen{1} +% |\listlen{1,2,3,4,5}| & \listlen{1,2,3,4,5} \\ +% |\listlen{}| & \listlen{} \\ +% |\listlen{1,2}| & \listlen{1,2} \\ +% |\listlen{1}| & \listlen{1} % \end{tabular} % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -236,17 +244,33 @@ % % \begin{tabular}{ll} % |\listlenstore{thelistlength}{1,2,3,4,5}| -% \\ -% |\arabic{thelistlength}| & \listlenstore{thelistlength}{1,2,3,4,5} \arabic{thelistlength} -% \\[1cm] +% \\ +% |\arabic{thelistlength}| & \listlenstore{thelistlength}{1,2,3,4,5} \arabic{thelistlength} +% \\[1cm] % |\listlenstore{thelistlength}{}| -% \\ -% |\arabic{thelistlength}| & \listlenstore{thelistlength}{} \arabic{thelistlength} -% \\[1cm] +% \\ +% |\arabic{thelistlength}| & \listlenstore{thelistlength}{} \arabic{thelistlength} +% \\[1cm] % \end{tabular} % % - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % +%\subsection{\texttt{$\backslash$listcopy}} +% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \DescribeMacro{\listcopy} copy elements of a list +% +% \begin{tabular}{ll} +% |\liststore{1,2,3}{temp}| \\ +% |\listcopy{temp}{copiedlist}| \\ +% |\copiedlisti;\copiedlistii;\copiedlistiii| & +% \liststore{1,2,3}{temp}\listcopy{temp}{copiedlist}\copiedlisti;\copiedlistii;\copiedlistiii +% \end{tabular} +% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %\subsection{\texttt{$\backslash$listsum}} % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % @@ -255,12 +279,16 @@ % \DescribeMacro{\listsum} Summing elements of lists % % \begin{tabular}{ll} -% |\listsum{1,2,3,4,5}{\thelistsum}| \\ -% |\thelistsum| & \listsum{1,2,3,4,5}{\thelistsum}\thelistsum \\[1cm] -% |\listsum{1,2,3,a,b,a,a}{\thelistsum}| \\ -% |\thelistsum| & \listsum{1,2,3,a,b,a,a}{\thelistsum}\thelistsum \\[1cm] -% |\listsum{a,b,c,d}{\thelistsum}| \\ -% |\thelistsum| & \listsum{a,b,c,d}{\thelistsum}\thelistsum +% |\listsum{1,2,3,4,5}{\thelistsum}| \\ +% |\thelistsum| & \listsum{1,2,3,4,5}{\thelistsum}\thelistsum \\[1cm] +% |\listsum{1,2,3,a,b,a,a}{\thelistsum}| \\ +% |\thelistsum| & \listsum{1,2,3,a,b,a,a}{\thelistsum}\thelistsum \\[1cm] +% |\liststore{1,2,3,5,j,k,j}{temp}| \\ +% |\listsum[liststored=true]{temp}{\thelistsum}| \\ +% |\thelistsum| & +% \liststore{1,2,3,5,j,k,j}{temp}\listsum[liststored=true]{temp}{\thelistsum}\thelistsum \\[1cm] +% |\listsum{a,b,c,d}{\thelistsum}| \\ +% |\thelistsum| & \listsum{a,b,c,d}{\thelistsum}\thelistsum % \end{tabular} % % @@ -320,40 +348,40 @@ % \begin{macrocode} \def\COOL@listgobble[#1]#2,#3,\COOL@listEnd{% \ifthenelse{\equal{#3}{\COOL@listStop}}% - {% + {% % \end{macrocode} % % we have reached the end of the list, just need to check if we need to output something % % \begin{macrocode} - \ifthenelse{\value{COOL@listpointer}=#1}% - {% - \setboolean{COOL@found}{true}% - #2% - }% - % Else - {% + \ifthenelse{\value{COOL@listpointer}=#1}% + {% + \setboolean{COOL@found}{true}% + #2% + }% + % Else + {% + }% }% - }% % Else - {% - \ifthenelse{\value{COOL@listpointer}=#1}% - {% - \setboolean{COOL@found}{true}% - #2% - }% - % Else {% - }% - \stepcounter{COOL@listpointer}% + \ifthenelse{\value{COOL@listpointer}=#1}% + {% + \setboolean{COOL@found}{true}% + #2% + }% + % Else + {% + }% + \stepcounter{COOL@listpointer}% % \end{macrocode} % % We must eat up the whole list no matter what or else the stuff beyond |#1| will be displayed. so we need % to call ``the gobbler" again. % % \begin{macrocode} - \COOL@listgobble[#1]#3,\COOL@listEnd% - }% + \COOL@listgobble[#1]#3,\COOL@listEnd% + }% }% % \end{macrocode} % @@ -379,31 +407,31 @@ % % \begin{macrocode} \ifthenelse{\equal{#1}{}}% - {% + {% % \end{macrocode} % % set the listpointer to zero because the list has no length % \begin{macrocode} - \setcounter{COOL@listpointer}{0}% - }% + \setcounter{COOL@listpointer}{0}% + }% % \end{macrocode} % % Else % % \begin{macrocode} - {% + {% % \end{macrocode} % % start at the beginning of the list, so initialize |listpointer| % % \begin{macrocode} - \setcounter{COOL@listpointer}{1}% + \setcounter{COOL@listpointer}{1}% % \end{macrocode} % % Assume that the target will not be found---it will be set to true by ``the gobbler" if it is % % \begin{macrocode} - \setboolean{COOL@found}{false}% + \setboolean{COOL@found}{false}% % \end{macrocode} % % Now call the gobbler---since the user shouldn't be forced to submit the end character (in fact @@ -412,8 +440,8 @@ % the entire list is read in by |\COOL@listgobbler| we need the list stop `character' too. % % \begin{macrocode} - \COOL@listgobble[#2]#1,\COOL@listStop,\COOL@listEnd% - }% + \COOL@listgobble[#2]#1,\COOL@listStop,\COOL@listEnd% + }% }% % \end{macrocode} % @@ -422,6 +450,7 @@ % % % \begin{macro}{\liststore} +% \changes{v1.3}{2007/10/14}{added code to store the length of the list} % \begin{macro}{\COOL@liststore@gobbler} % The list may be stored in a macro of the user's choosing with the function. The syntax is % @@ -446,19 +475,23 @@ % \begin{macrocode} \def\COOL@liststore@gobbler[#1]#2,#3,\COOL@listEnd{% \ifthenelse{\equal{#3}{\COOL@listStop}}% - {% - \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% - }% + {% + \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% + }% % Else - {% - \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% - \stepcounter{COOL@listpointer}% - \COOL@liststore@gobbler[#1]#3,\COOL@listEnd% - }% + {% + \expandafter\gdef\csname #1\roman{COOL@listpointer}\endcsname{#2}% + \stepcounter{COOL@listpointer}% + \COOL@liststore@gobbler[#1]#3,\COOL@listEnd% + }% } \newcommand{\liststore}[2]{% \setcounter{COOL@listpointer}{1}% \COOL@liststore@gobbler[#2]#1,\COOL@listStop,\COOL@listEnd% +% \end{macrocode} +% Now store the length +% \begin{macrocode} +\expandafter\xdef\csname #2length\endcsname{\arabic{COOL@listpointer}}% }% % \end{macrocode} % \end{macro} @@ -507,8 +540,37 @@ % % % +% +% \begin{macro}{\listcopy} +% \changes{v1.3}{2007/10/14}{added this function to the package} +% +% This copies one list into another element by element. +% +% \begin{macrocode} +\newcommand{\listcopy}[2]{% +% \end{macrocode} +% Store the length of the list to be copied +% \begin{macrocode} +\setcounter{COOL@listlen}{\csname #1length\endcsname}% +% \end{macrocode} +% go through each element of the list and copy it to the new list +% \begin{macrocode} +\forloop{COOL@listpointer}{1}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% + {% + \expandafter\xdef\csname #2\roman{COOL@listpointer}\endcsname{\csname #1\roman{COOL@listpointer}\endcsname}% + }% +\expandafter\xdef\csname #2length\endcsname{\csname #1length\endcsname}% +} +% \end{macrocode} +% +% \end{macro} +% +% +% +% % \begin{macro}{\listsum} % \changes{v1.2}{2007/10/10}{added this function to the package} +% \changes{v1.3}{2007/10/14}{altered function to take optional argument for summing stored lists} % Sum the contents of the list. Integers are recognized and summed, tokens are treated as independent variables. % The function returns a string of the sum % @@ -529,145 +591,166 @@ % Now the function % % \begin{macrocode} -\newcommand{\listsum}[2]{% +\newcommand{\listsum}[3][liststored=false]{% +% \end{macrocode} +% Check to see if the list is already stored. If it is, copy it; otherwise store it +% \begin{macrocode} +\ifthenelse{ \equal{#1}{liststored=false} }% + {% % \end{macrocode} % First store the entire list % \begin{macrocode} -\liststore{#1}{COOL@listtosum@element@}% + \liststore{#2}{COOL@listtosum@element@}% % \end{macrocode} % store the length of the list % \begin{macrocode} -\listlenstore{COOL@listlen}{#1}% + \listlenstore{COOL@listlen}{#2}% + }% % \end{macrocode} -% check for the list having a non-zero length +% ElseIf % \begin{macrocode} -\ifthenelse{ \value{COOL@listlen} < 1 }% - {% - \PackageWarning{cool}{List is empty}% - \xdef#2{0}% - }% +{ \ifthenelse{ \equal{#1}{liststored=true} }% + {% + \listcopy{#2}{COOL@listtosum@element@}% + \setcounter{COOL@listlen}{\COOL@listtosum@element@length}% + }% % \end{macrocode} % Else % \begin{macrocode} - {% + {% + \PackageError{cool}{Invalid listsum optional argument}% + {listsum's optional argument may only be `storedlist=true' or `storedlist=false'}% + }}% % \end{macrocode} -% put the first list element into the register +% check for the list having a non-zero length % \begin{macrocode} - \isint{\COOL@listtosum@element@i}{COOL@listsum@isint}% - \ifthenelse{ \boolean{COOL@listsum@isint} }% +\ifthenelse{ \value{COOL@listlen} < 1 }% {% - \xdef\COOL@listsum@register@integers{\COOL@listtosum@element@i}% - \setcounter{COOL@register@len}{0}% + \PackageWarning{cool}{List is empty}% + \xdef#3{0}% }% % \end{macrocode} -% Else +% Else % \begin{macrocode} {% % \end{macrocode} -% Initialize the integers register to zero; store the character and its coefficient +% put the first list element into the register % \begin{macrocode} - \gdef\COOL@listsum@register@integers{0}% - \xdef\COOL@listsum@register@i{\COOL@listtosum@element@i}% - \gdef\COOL@listsum@register@coef@i{1}% - \setcounter{COOL@register@len}{1}% - }% + \isint{\COOL@listtosum@element@i}{COOL@listsum@isint}% + \ifthenelse{ \boolean{COOL@listsum@isint} }% + {% + \xdef\COOL@listsum@register@integers{\COOL@listtosum@element@i}% + \setcounter{COOL@register@len}{0}% + }% % \end{macrocode} -% Now go through each additional element making an index of the symbols and summing identical ones +% Else % \begin{macrocode} - \forloop{COOL@listpointer}{2}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% - {% + {% % \end{macrocode} -% Expand the element to a convenient storage macro +% Initialize the integers register to zero; store the character and its coefficient % \begin{macrocode} - \xdef\COOL@listsum@element{\csname COOL@listtosum@element@\roman{COOL@listpointer}\endcsname}% + \gdef\COOL@listsum@register@integers{0}% + \xdef\COOL@listsum@register@i{\COOL@listtosum@element@i}% + \gdef\COOL@listsum@register@coef@i{1}% + \setcounter{COOL@register@len}{1}% + }% % \end{macrocode} -% Check if this element is an integer +% Now go through each additional element making an index of the symbols and summing identical ones % \begin{macrocode} - \isint{\COOL@listsum@element}{COOL@listsum@isint}% - \ifthenelse{ \boolean{COOL@listsum@isint} }% - {% + \forloop{COOL@listpointer}{2}{\NOT \value{COOL@listpointer} > \value{COOL@listlen}}% + {% % \end{macrocode} -% Grab the current value of the integers and store it in the register counter +% Expand the element to a convenient storage macro % \begin{macrocode} - \setcounter{COOL@intsum}{\COOL@listsum@register@integers}% - \addtocounter{COOL@intsum}{\COOL@listsum@element}% - \xdef\COOL@listsum@register@integers{\arabic{COOL@intsum}}% - }% + \xdef\COOL@listsum@element{\csname COOL@listtosum@element@\roman{COOL@listpointer}\endcsname}% % \end{macrocode} -% Else, it's not an integer so search to see if it matches known elements +% Check if this element is an integer % \begin{macrocode} - {% - \setboolean{COOL@found}{false}% - \forloop{COOL@register@ct}{1}{\NOT \value{COOL@register@ct} > \value{COOL@register@len}}% - {% - \xdef\COOL@listsum@known@element{% - \csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname% - }% - \ifthenelse{ \equal{\COOL@listsum@element}{\COOL@listsum@known@element} }% - {% + \isint{\COOL@listsum@element}{COOL@listsum@isint}% + \ifthenelse{ \boolean{COOL@listsum@isint} }% + {% % \end{macrocode} -% found the element so increment the coefficient -% (grab coefficient, store in ct, increment ct, store new ct) +% Grab the current value of the integers and store it in the register counter % \begin{macrocode} - \xdef\COOL@listsum@known@element@coef{% - \csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname% + \setcounter{COOL@intsum}{\COOL@listsum@register@integers}% + \addtocounter{COOL@intsum}{\COOL@listsum@element}% + \xdef\COOL@listsum@register@integers{\arabic{COOL@intsum}}% }% - \setcounter{COOL@intsum}{\COOL@listsum@known@element@coef}% - \addtocounter{COOL@intsum}{1}% - \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname{\arabic{COOL@intsum}}% % \end{macrocode} -% flag the element as found and set the counter to the length of the register $+1$ +% Else, it's not an integer so search to see if it matches known elements % \begin{macrocode} - \setboolean{COOL@found}{true}% - }% + {% + \setboolean{COOL@found}{false}% + \forloop{COOL@register@ct}{1}{\NOT \value{COOL@register@ct} > \value{COOL@register@len}}% + {% + \xdef\COOL@listsum@known@element{% + \csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname% + }% + \ifthenelse{ \equal{\COOL@listsum@element}{\COOL@listsum@known@element} }% + {% % \end{macrocode} -% Else do nothing +% found the element so increment the coefficient +% (grab coefficient, store in ct, increment ct, store new ct) % \begin{macrocode} - {% - }% - }% + \xdef\COOL@listsum@known@element@coef{% + \csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname% + }% + \setcounter{COOL@intsum}{\COOL@listsum@known@element@coef}% + \addtocounter{COOL@intsum}{1}% + \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname{\arabic{COOL@intsum}}% % \end{macrocode} -% Check to see if the element is a known element. If not, add it to the register +% flag the element as found and set the counter to the length of the register $+1$ % \begin{macrocode} - \ifthenelse{ \boolean{COOL@found} }% - {}% + \setboolean{COOL@found}{true}% + }% % \end{macrocode} -% Else +% Else do nothing % \begin{macrocode} - {% - \addtocounter{COOL@register@len}{1}% - \expandafter\xdef\csname COOL@listsum@register@\roman{COOL@register@len}\endcsname{\COOL@listsum@element}% - \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@len}\endcsname{1}% + {% + }% + }% +% \end{macrocode} +% Check to see if the element is a known element. If not, add it to the register +% \begin{macrocode} + \ifthenelse{ \boolean{COOL@found} }% + {}% +% \end{macrocode} +% Else +% \begin{macrocode} + {% + \addtocounter{COOL@register@len}{1}% + \expandafter\xdef\csname COOL@listsum@register@\roman{COOL@register@len}\endcsname{\COOL@listsum@element}% + \expandafter\xdef\csname COOL@listsum@register@coef@\roman{COOL@register@len}\endcsname{1}% + }% + }% }% - }% - }% % \end{macrocode} -% Finally, create and store the sum -% \begin{macrocode} - \xdef\COOL@listsum@result{}% - \ifthenelse{ \NOT \COOL@listsum@register@integers = 0 }% - { - \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@register@integers}% - \ifthenelse{ \NOT \value{COOL@register@len} = 0 }% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result+}% - }{}% - }{}% - \forloop{COOL@register@ct}{1}{ \NOT \value{COOL@register@ct} > \value{COOL@register@len} }% - {% - \edef\COOL@listsum@curcoef{\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname}% - \ifthenelse{ \NOT \COOL@listsum@curcoef = 1}% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@curcoef}% - }{}% - \xdef\COOL@listsum@result{\COOL@listsum@result\csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname}% - \ifthenelse{ \NOT \value{COOL@register@ct} = \value{COOL@register@len} }% - {% - \xdef\COOL@listsum@result{\COOL@listsum@result+}% - }{}% +% Finally, create and store the sum +% \begin{macrocode} + \xdef\COOL@listsum@result{}% + \ifthenelse{ \NOT \COOL@listsum@register@integers = 0 }% + { + \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@register@integers}% + \ifthenelse{ \NOT \value{COOL@register@len} = 0 }% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result+}% + }{}% + }{}% + \forloop{COOL@register@ct}{1}{ \NOT \value{COOL@register@ct} > \value{COOL@register@len} }% + {% + \edef\COOL@listsum@curcoef{\csname COOL@listsum@register@coef@\roman{COOL@register@ct}\endcsname}% + \ifthenelse{ \NOT \COOL@listsum@curcoef = 1}% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result\COOL@listsum@curcoef}% + }{}% + \xdef\COOL@listsum@result{\COOL@listsum@result\csname COOL@listsum@register@\roman{COOL@register@ct}\endcsname}% + \ifthenelse{ \NOT \value{COOL@register@ct} = \value{COOL@register@len} }% + {% + \xdef\COOL@listsum@result{\COOL@listsum@result+}% + }{}% + }% + \xdef#3{\COOL@listsum@result}% }% - \xdef#2{\COOL@listsum@result}% - }% } % \end{macrocode} % -- cgit v1.2.3