Changes

Jump to navigation Jump to search
987 bytes added ,  01:09, 4 August 2005
Added real example to dash-separated-lists section.
=== Processing a dash-separated list of values ===
Sometimes you have more work to do than just that borring boring stuff at home. And as it is quite important as well, you don't want to loose your time enumerating all of the tasks. Being able to do something like
<texcode>
\IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow}
</texcode>
Guess what! Your <tt>\IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow}</tt> resulted results in: <context>\def\IHaveToDoTheTask[#1]#2{The task #1 has to be done until tomorrow#2.\par} The task 2 has % a few auxiliary core macros are needed to be done until tomorrowuncompress the list. The task 3 has to be done until tomorrow%% \uncompresslist is the twin of the already existing \compresslist% which works in the other direction (syst-new)%\unprotect % I guess this function is already available but couldnt find it... The task 4 has to be done until tomorrow.%\def\apptomac#1#2% {\ifx#1\empty\def#1{#2}\else \@EA\def\@EA#1\@EA{#1,#2}\fi} % the next macro does this:% The task 7 has to be done until tomorrow.% \itemwithdash<<9-11>>- => \dorecurse {<<1+11-9>>} The task % {\apptomac\uncompressedlist<<9 has -1+\recurselevel>>}%% (the 1+ and -1 are needed to be done until tomorrowsolve a counter offset.) \def\itemwithdash#1-#2-% {\@EA\dorecurse\@EA {\the\numexpr 1+#2-#1\relax}% {\@EA\apptomac\@EA\uncompressedlist\@EA {\the\numexpr #1-1+\recurselevel\relax}}}% % top level. The task 10 has to result will be done until tomorrow.in \uncompressedlist\def\uncompresslist[#1]% {\def\uncompressedlist{}% \def\processitem##1% {\doifinstringelse{-}{##1} {\itemwithdash##1-} {\apptomac\uncompressedlist{##1}}}% \processcommalist[#1]\processitem } \protect \def\IHaveToDoTheTasks[#1]#2% {\begingroup \uncompresslist[#1]% <= Yeah! \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% \processcommacommand[\uncompressedlist]\processitem \endgroup}  The task \IHaveToDoTheTasks[1-4,7,9-11 has to be done ]{until tomorrow.}</context>
So - what are you still waiting for? Go back to work and do them right away!
Anonymous user

Navigation menu