% \iffalse
%
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{coollist}
%<package> [2006/08/14 v1 COntent Oriented LaTeX Lists]
%<package>\RequirePackage{ifthen}
%<package>\RequirePackage{amsmath}
%<package>\RequirePackage{amssymb}
%
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{coollist}
\usepackage{url}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{coollist.dtx}
\end{document}
%</driver>
% \fi
%
% \iffalse meta-comment
% remove this comment to get a checksum
% \CheckSum{0}
% \fi
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \changes{v1.0}{2006/08/14}{Initial Release}
%
% \GetFileInfo{coollist.sty}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\!,\(,\),\,}
% \DoNotIndex{\@ne,\expandafter}
% \DoNotIndex{\advance,\begingroup,\catcode,\closein}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand}
% \DoNotIndex{\closeout,\day,\def,\edef,\gdef,\let,\empty,\endgroup}
% \DoNotIndex{\newcounter,\providecounter,\addtocounter,\setcounter,\stepcounter,\value,\arabic}
% \DoNotIndex{\if,\fi,\ifthenelse,\else,\setboolean,\boolean,\newboolean,\provideboolean,\equal,\AND,\OR,\NOT,\whiledo}
% \DoNotIndex{\ifcase,\ifcat,\or,\else}
% \DoNotIndex{\par,\parbox,\mbox,\hbox,\begin,\end,\nabla,\partial}
% \DoNotIndex{\overline,\bar,\small,\tiny,\mathchoice,\scriptsize,\textrm,\texttt}
% \DoNotIndex{\alpha,\beta,\gamma,\epsilon,\varepsilon,\delta,\zeta,\eta,\theta,\vartheta,\iota,\kappa,\lambda,\mu,\nu}
% \DoNotIndex{\xi,\omicron,\pi,\varpi,\rho,\varrho,\sigma,\tau,\upsilon,\phi,\varphi,\chi,\psi,\omega}
% \DoNotIndex{\Delta,\Gamma,\Theta,\Lambda,\Xi,\Pi,\Sigma,\Phi,\Psi,\Omega}
% \DoNotIndex{\digamma,\lceil,\rceil,\lfloor,\rfloor,\left,\right,\inp,\inb,\inbr,\inap,\nop}
% \DoNotIndex{\sum,\prod,\int,\log,\ln,\exp,\sin,\cos,\tan,\csc,\sec,\cot,\arcsin,\arccos,\arctan,\det}
% \DoNotIndex{\sinh,\cosh,\tanh,\csch,\sech,\coth,\arcsinh,\arccosh,\arctanh}
% \DoNotIndex{\mod,\max,\min,\gcd,\lcm,\wp,\arg,\dots,\infty,}
% \DoNotIndex{\frac,\binom,\braket,\@@atop}
% \DoNotIndex{\cdot,\ldots,\tilde,\times,\dagger,\relax}
% \DoNotIndex{\mathbb,\roman,\bf,\mathord,\cal,\DeclareMathOperator,\PackageError,\PackageWarning}
% \DoNotIndex{\csname,\endcsname,\ifx,\ifnum}
% \DoNotIndex{\COOL@Hypergeometric@pq,\COOL@Hypergeometric@pq@ab@value,\hideOnSF,\COOL@decide@paren}
% \DoNotIndex{\COOL@decide@indicies}
% \DoNotIndex{\mod,\bmod,\pmod,\pod,\operatorname}
% \DoNotIndex{\forLoop}
% \DoNotIndex{\listval,\liststore,\isint,\isnumeric}
% \DoNotIndex{
% \COOL@list@temp@i,
% \COOL@list@temp@ii,
% \COOL@list@temp@iii}
%
% \title{The \textsf{coollist} package\thanks{This document
% corresponds to \textsf{coollist}~\fileversion,
% dated~\filedate.}}
% \author{nsetzer}
%
% \maketitle
%
% \setcounter{IndexColumns}{2}
% \StopEventually{\PrintChanges\PrintIndex}
%
% The \textsf{coollist} package is a ``sub" package of the \textsf{cool} package that seemed appropriate to publish
% independently since it may occur that one wishes to include the ability to manipulate lists without having to accept 
% all the overhead of the \textsf{cool} package itself.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Basics}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Lists are defined as a sequence of tokens separated by a comma.  The \textsf{coollist} package allows the user
% to access certain elements of the list while neglecting others---essentially turning lists into a sort of
% array. 
%
% Lists elements are accessed by specifying the position of the object within the list (the index of the item)
% Lists start indexing at |1|.
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Implementation}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is just an internal counter for dealing with the lists, most often used for the length of the list.
%
%    \begin{macrocode}
\newcounter{COOL@listlen}%
%    \end{macrocode}
%
%
% \begin{macro}{\setlistEnd}
% \begin{macro}{\setlistStop}
%
% |\setlistStop{|\meta{string}|}| and |\setlistEnd{|\meta{string}|}| allow the user to set the end of a list `character's 
% in the rare event that the default values actually appear in the list.
% Both of these entities are required to properly deliminate the list and avoid errors when macros are included in the list.  The default values are
%
%    \begin{macrocode}
\newcommand{\COOL@listEnd}{@@@}%
\newcommand{\COOL@listStop}{@@}%
%    \end{macrocode}
%
% and they may be changed by the following commands (which utilize the |\renewcommand|):
%
%    \begin{macrocode}
\newcommand{\setlistStop}[1]{\renewcommand{\COOL@listStop}{#1}}%
\newcommand{\setlistEnd}[1]{\renewcommand{\COOL@listEnd}{#1}}%
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
%
%
% This area defines the core technology behind the \textsf{coollist} package: the list ``gobbler".
% To properly eat a list a counter and a boolean need to be used.  |listpointer| acts just like the name
% implies, as the current ``position" of the list.  |found| indicates that the position has been found
%
%    \begin{macrocode}
\newcounter{COOL@listpointer}%
\newboolean{COOL@found}%
%    \end{macrocode}
%
% Now we come to ``the gobbler"---a recursive function that eats up a list and gives back the appropriate item.  
% This must be done in \TeX{} primatives.
%
% The idea behind this is that ``the gobbler" eats up everything before the desired item and everything 
% after the desired item.
%
%    \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
		{%
		}%
	}%
% Else
	{%
	\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%
	}%
}%
%    \end{macrocode}
%
%
%
%
% \begin{macro}{\listval}
%
% |\listval|\marg{comma\_deliminated\_list}\marg{index} 
%
% gives the \meta{index} value of \meta{comma\_deliminated\_list}---as in
%
% |\listval{1,2,3,4,5,6}{3}| = \listval{1,2,3,4,5,6}{3}
%
% |$\listval{\alpha,\beta,\gamma}{2}$| = $\listval{\alpha,\beta,\gamma}{2}$
%
%    \begin{macrocode}
\newcommand{\listval}[2]{%
%    \end{macrocode}
%
% start at the beginning of the list, so initialize |listpointer|
%
%    \begin{macrocode}
   \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}% 
%    \end{macrocode}
%
% Now call the gobbler---since the user shouldn't be forced to submit the end character (in fact 
% he or she shouldn't even need to worry that an end character exists nor what it is), we add it
% on along with the `optional' parameter that tells us which element to retreive.  To ensure that
% 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%
}%
%    \end{macrocode}
%
% \end{macro}
%
%
%
% \begin{macro}{\liststore}
% \begin{macro}{\COOL@liststore@gobbler}
% The list may be stored in a macro of the user's choosing with the function.  The syntax is 
%
% |\liststore|\marg{csv\_list}\marg{macro\_base\_name}
%
% and the resulting list elements are stored in
%
% \meta{macro\_base\_name}\meta{list\_index\_roman} 
%
% where \meta{list\_index\_roman} is the list index in roman numerals.
%
% Some examples will clarify:
%
% |\liststore{1,2,3,4}{temp}| \liststore{1,2,3,4}{temp}
%
% \noindent |\tempi;\tempii;\tempiii;\tempiv| yields \tempi;\tempii;\tempiii;\tempiv
%
%
% \noindent |\liststore{a_1,a_2,a_3,a_4}{temp}| \liststore{a_1,a_2,a_3,a_4}{temp}
%
% \noindent |\tempi;\tempii;\tempiii;\tempiv| yields $\tempi;\tempii;\tempiii;\tempiv$
%    \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}%
	}%
% Else
	{%
	\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}
% \end{macro}
% \end{macro}
%
%
%
%
%
% \begin{macro}{\listlen}
%
% This returns the length of the list, though it is not useful for storing this length.  If you need to record the
% list's length for later use, it is better to use the next function |\listlenstore|.
%
% The format is |\listlen|\marg{comma deliminated list}.  It works by recording
% the value of |listpointer| after it has complete traversed the list.  Since indexing starts at |1|, it uses the
% index |0| which will never ever be an index of the list, so ``the gobbler" will not return any value.
%
% Example: |\listlen{1,2,3,4,5}| = \listlen{1,2,3,4,5}
%
%    \begin{macrocode}
\newcommand{\listlen}[1]{%
\listval{#1}{0}%
\arabic{COOL@listpointer}
}%listlength
%    \end{macrocode}
%
% \end{macro}
%
%
%
%
% \begin{macro}{\listlenstore}
%
% This store the length of the list.  The format is |\listlenstore|\marg{counter}\marg{comma deliminated list}.  
%
%    \begin{macrocode}
\newcommand{\listlenstore}[2]{%
\listval{#2}{0}%
\setcounter{#1}{\value{COOL@listpointer}}
}%listlength
%    \end{macrocode}
%
% \end{macro}
%
%
%
%
% \Finale
\endinput