Re: [NTG-context] How to \processcommalist inside another commalist?
On 8/21/06, Taco Hoekwater wrote: > nico wrote: > > \def\arePrimeN[#1]{% > > \bgroup > > \getparameters[Prime][p=,#1] > > \expandafter\processcommalist\expandafter[\Primep]\printPrime > > \egroup} > > And an equivalent is > >\processcommacommand[\Primep]\printPrime On 8/21/06, Taco Hoekwater wrote: > Mojca Miklavec wrote: > > > > At the beginning the main reason against it was that I didn't know how > > to distinguish which kind of parameters are being used in the second > > pair of brackets, but I guess that I can safely use \ifnumberelse as a > > test on the first item to distinguish between the two. > > You could look up \doifassignmentelse in the sources. Thank you, the two commands (including Hans's additional hints) solved "all" my questions (for now.) Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
nico wrote: > On Mon, 21 Aug 2006 23:08:59 +0200, Hans Hagen <[EMAIL PROTECTED]> wrote: > > but after some thinking I realized that it would indeed be a better idea (less to type?) to have \useGNUPLOTgraphic[name][1,3] and \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] instead. At the beginning the main reason against it was that I didn't know how to distinguish which kind of parameters are being used in the second pair of brackets, but I guess that I can safely use \ifnumberelse as a test on the first item to distinguish between the two. >>> Maybe you could play only with the parameter count. The limitation is >>> that >>> an empty second argument is required when only options need to be >>> passed. >>> >>> >> why? in that case #3 is empty and #2 contains the options >> > > Hm, I thought that the initial goal was to know if the parameter passed is > a number list, or an option list. In the suggested code, the assumption is > that the number list (if any) is always the second parameter. > > If not, how to handle those cases? > > \useGNUPLOTgraphic[name][2,3,5] > \useGNUPLOTgraphic[name][width=2in] > > But I guess there are clever internal macros that could help :-) > as already mentioned: \doifassignmentelse{#2}{...}{...} - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
On Mon, 21 Aug 2006 23:08:59 +0200, Hans Hagen <[EMAIL PROTECTED]> wrote: >>> but after some thinking I realized that it would indeed be a better >>> idea (less to type?) to have >>> \useGNUPLOTgraphic[name][1,3] >>> and >>> \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] >>> instead. >>> >>> At the beginning the main reason against it was that I didn't know how >>> to distinguish which kind of parameters are being used in the second >>> pair of brackets, but I guess that I can safely use \ifnumberelse as a >>> test on the first item to distinguish between the two. >>> >> >> Maybe you could play only with the parameter count. The limitation is >> that >> an empty second argument is required when only options need to be >> passed. >> > why? in that case #3 is empty and #2 contains the options Hm, I thought that the initial goal was to know if the parameter passed is a number list, or an option list. In the suggested code, the assumption is that the number list (if any) is always the second parameter. If not, how to handle those cases? \useGNUPLOTgraphic[name][2,3,5] \useGNUPLOTgraphic[name][width=2in] But I guess there are clever internal macros that could help :-) Regards, BG >> \def\printPrime#1{#1 is prime.\crlf} >> >> \def\useGNUPLOTgraphic >>{\dotripleempty\douseGNUPLOTgraphic} >> >> \def\douseGNUPLOTgraphic[#1][#2][#3]% >>{\ifthirdargument >> \doprime{#2} >> parameters are #3 >> \getparameters[gnuplot][#3] >> \else\ifsecondargument >> \doprime{#2} >> \fi\fi} >> >> \def\doprime#1{\processcommalist[#1]\printPrime} >> >> \starttext >> \useGNUPLOTgraphic[name] >> \useGNUPLOTgraphic[name][2,3,5] >> \useGNUPLOTgraphic[name][3,5,7][width=2in] >> \useGNUPLOTgraphic[name][][width=4in] >> \stoptext ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
Mojca Miklavec wrote: > On 8/21/06, nico wrote: > >> On Mon, 21 Aug 2006 17:23:48 +0200, Mojca Miklavec wrote: >> >> >>> Hello, >>> >>> I tried to print out primes (well, I tried to do something else, but I >>> needed a more illustrative example), but it seems that my approach was >>> too naive: >>> >>> \def\arePrime[#1]{% >>> \bgroup >>> \getparameters[Prime][p=,#1] >>> \def\printPrime##1{##1 is prime.\crlf} >>> \processcommalist[\Primep]\printPrime >>> \egroup} >>> >>> \starttext >>> \arePrime[p={2,3,5}] >>> \stoptext >>> >> My 2 cents contribution: >> >> \def\printPrime#1{#1 is prime.\crlf} >> >> %% Why using parameter for this? >> > > I was sure that someone would ask that. I want to provide optional > parameters for both numbers and scaling: > \useGNUPLOTgraphic[name] > or > \useGNUPLOTgraphic[name][width=.9\textwidth] > or > \useGNUPLOTgraphic[name][n={1,3}] > or > \useGNUPLOTgraphic[name][n={1,3},width=.9\textwidth] > > but after some thinking I realized that it would indeed be a better > idea (less to type?) to have > \useGNUPLOTgraphic[name][1,3] > and > \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] > instead. > > along these lines: \def\useGNUPLOTgraphic {\dotripleempty\douseGNUPLOTgraphic} \def\douseGNUPLOTgraphic[#1][#2][#3]% {\itthirdargument \dodouseGNUPLOTgraphic[#1][#2][#3]% \else\ifsecondargument \def\docommand##1{\dodouseGNUPLOTgraphic[#1][##1][#3]}% \processcommalist[#2]\docommand \fi} \def\dodouseGNUPLOTgraphic[#1][#2][#3]% {\getparameters[#1:#2][#3]} etc etc you can also check for \doifsssignmentelse{#2}{...}{...} > At the beginning the main reason against it Hans -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
nico wrote: > On Mon, 21 Aug 2006 20:35:27 +0200, Mojca Miklavec > <[EMAIL PROTECTED]> wrote: > > >>> %% Why using parameter for this? >>> >> I was sure that someone would ask that. I want to provide optional >> parameters for both numbers and scaling: >> \useGNUPLOTgraphic[name] >> or >> \useGNUPLOTgraphic[name][width=.9\textwidth] >> or >> \useGNUPLOTgraphic[name][n={1,3}] >> or >> \useGNUPLOTgraphic[name][n={1,3},width=.9\textwidth] >> >> but after some thinking I realized that it would indeed be a better >> idea (less to type?) to have >> \useGNUPLOTgraphic[name][1,3] >> and >> \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] >> instead. >> >> At the beginning the main reason against it was that I didn't know how >> to distinguish which kind of parameters are being used in the second >> pair of brackets, but I guess that I can safely use \ifnumberelse as a >> test on the first item to distinguish between the two. >> > > Maybe you could play only with the parameter count. The limitation is that > an empty second argument is required when only options need to be passed. > why? in that case #3 is empty and #2 contains the options > \def\printPrime#1{#1 is prime.\crlf} > > \def\useGNUPLOTgraphic >{\dotripleempty\douseGNUPLOTgraphic} > > \def\douseGNUPLOTgraphic[#1][#2][#3]% >{\ifthirdargument > \doprime{#2} > parameters are #3 > \getparameters[gnuplot][#3] > \else\ifsecondargument > \doprime{#2} > \fi\fi} > > \def\doprime#1{\processcommalist[#1]\printPrime} > > \starttext > \useGNUPLOTgraphic[name] > \useGNUPLOTgraphic[name][2,3,5] > \useGNUPLOTgraphic[name][3,5,7][width=2in] > \useGNUPLOTgraphic[name][][width=4in] > \stoptext > > Regards, > BG > ___ > ntg-context mailing list > ntg-context@ntg.nl > http://www.ntg.nl/mailman/listinfo/ntg-context > -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
Mojca Miklavec wrote: > > At the beginning the main reason against it was that I didn't know how > to distinguish which kind of parameters are being used in the second > pair of brackets, but I guess that I can safely use \ifnumberelse as a > test on the first item to distinguish between the two. You could look up \doifassignmentelse in the sources. Cheers, taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
On Mon, 21 Aug 2006 20:35:27 +0200, Mojca Miklavec <[EMAIL PROTECTED]> wrote: >> %% Why using parameter for this? > > I was sure that someone would ask that. I want to provide optional > parameters for both numbers and scaling: > \useGNUPLOTgraphic[name] > or > \useGNUPLOTgraphic[name][width=.9\textwidth] > or > \useGNUPLOTgraphic[name][n={1,3}] > or > \useGNUPLOTgraphic[name][n={1,3},width=.9\textwidth] > > but after some thinking I realized that it would indeed be a better > idea (less to type?) to have > \useGNUPLOTgraphic[name][1,3] > and > \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] > instead. > > At the beginning the main reason against it was that I didn't know how > to distinguish which kind of parameters are being used in the second > pair of brackets, but I guess that I can safely use \ifnumberelse as a > test on the first item to distinguish between the two. Maybe you could play only with the parameter count. The limitation is that an empty second argument is required when only options need to be passed. \def\printPrime#1{#1 is prime.\crlf} \def\useGNUPLOTgraphic {\dotripleempty\douseGNUPLOTgraphic} \def\douseGNUPLOTgraphic[#1][#2][#3]% {\ifthirdargument \doprime{#2} parameters are #3 \getparameters[gnuplot][#3] \else\ifsecondargument \doprime{#2} \fi\fi} \def\doprime#1{\processcommalist[#1]\printPrime} \starttext \useGNUPLOTgraphic[name] \useGNUPLOTgraphic[name][2,3,5] \useGNUPLOTgraphic[name][3,5,7][width=2in] \useGNUPLOTgraphic[name][][width=4in] \stoptext Regards, BG ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
On 8/21/06, nico wrote: > On Mon, 21 Aug 2006 17:23:48 +0200, Mojca Miklavec wrote: > > > Hello, > > > > I tried to print out primes (well, I tried to do something else, but I > > needed a more illustrative example), but it seems that my approach was > > too naive: > > > > \def\arePrime[#1]{% > > \bgroup > > \getparameters[Prime][p=,#1] > > \def\printPrime##1{##1 is prime.\crlf} > > \processcommalist[\Primep]\printPrime > > \egroup} > > > > \starttext > > \arePrime[p={2,3,5}] > > \stoptext > > My 2 cents contribution: > > \def\printPrime#1{#1 is prime.\crlf} > > %% Why using parameter for this? I was sure that someone would ask that. I want to provide optional parameters for both numbers and scaling: \useGNUPLOTgraphic[name] or \useGNUPLOTgraphic[name][width=.9\textwidth] or \useGNUPLOTgraphic[name][n={1,3}] or \useGNUPLOTgraphic[name][n={1,3},width=.9\textwidth] but after some thinking I realized that it would indeed be a better idea (less to type?) to have \useGNUPLOTgraphic[name][1,3] and \useGNUPLOTgraphic[name][1,3][width=.9\textwidth] instead. At the beginning the main reason against it was that I didn't know how to distinguish which kind of parameters are being used in the second pair of brackets, but I guess that I can safely use \ifnumberelse as a test on the first item to distinguish between the two. > %% Expand the parameter before processing > \def\arePrimeN[#1]{% > \bgroup > \getparameters[Prime][p=,#1] > \expandafter\processcommalist\expandafter[\Primep]\printPrime > \egroup} On 8/21/06, Taco Hoekwater wrote: > And an equivalent is > >\processcommacommand[\Primep]\printPrime Thanks to both of you! Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
nico wrote: > \def\arePrimeN[#1]{% > \bgroup > \getparameters[Prime][p=,#1] > \expandafter\processcommalist\expandafter[\Primep]\printPrime > \egroup} And an equivalent is \processcommacommand[\Primep]\printPrime Cheers, Taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to \processcommalist inside another commalist?
On Mon, 21 Aug 2006 17:23:48 +0200, Mojca Miklavec <[EMAIL PROTECTED]> wrote: > Hello, > > I tried to print out primes (well, I tried to do something else, but I > needed a more illustrative example), but it seems that my approach was > too naive: > > \def\arePrime[#1]{% > \bgroup > \getparameters[Prime][p=,#1] > \def\printPrime##1{##1 is prime.\crlf} > \processcommalist[\Primep]\printPrime > \egroup} > > \starttext > \arePrime[p={2,3,5}] > \stoptext My 2 cents contribution: \def\printPrime#1{#1 is prime.\crlf} %% Why using parameter for this? \def\arePrime[#1]{% \bgroup \processcommalist[#1]\printPrime \egroup} %% Expand the parameter before processing \def\arePrimeN[#1]{% \bgroup \getparameters[Prime][p=,#1] \expandafter\processcommalist\expandafter[\Primep]\printPrime \egroup} \starttext \arePrime[2,3,5] \arePrimeN[p={2,3,5}] \stoptext Regards, BG ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
[NTG-context] How to \processcommalist inside another commalist?
Hello, I tried to print out primes (well, I tried to do something else, but I needed a more illustrative example), but it seems that my approach was too naive: \def\arePrime[#1]{% \bgroup \getparameters[Prime][p=,#1] \def\printPrime##1{##1 is prime.\crlf} \processcommalist[\Primep]\printPrime \egroup} \starttext \arePrime[p={2,3,5}] \stoptext I expected something like 2 is prime. 3 is prime. 5 is prime. But I got 2,3,5 is prime. Any suggestions or hints about how to change the macro to produce the desired result (using the same input)? Thank you a lot, Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"?
Mojca Miklavec wrote: Taco's solution already solved my problem, but I believe it would be nice to add some \processenumeratedlist (well, some better name should be given!) command to ConTeXt one day. That way it would be possible to process some commands like \filterpages[file.pdf][1,3,5] also with \filterpages[file.pdf][1-3,5,7-11] ah, you stopped rading page-imp.tex too early, there's also: \def\dowithrange#1#2% #2 takes number {\beforesplitstring#1\at:\to\fromrange \aftersplitstring #1\at:\to\torange \ifx\torange\empty\let\torange\fromrange\fi \dostepwiserecurse\fromrange\torange1{#2{\recurselevel}}} but we can indeed make a nicer looking one Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"?
Hans Hagen wrote: > Mojca Miklavec wrote: > > Taco Hoekwater wrote: > >>Mojca Miklavec wrote: > >> > >>>I would like to define a command, which would be called in the following > >>>way: > >>>\TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} > >>> > >>>so that it would be equivalent to: > >>>\WeHaveToDo[monday]{tidy up} > >>>\WeHaveToDo[wednesday]{tidy up} > >>>\WeHaveToDo[thursday]{tidy up} > > Actually, there is an easier way to do this; just swap the arguments to > WeHaveToDo: > > \def\TheBossWantsTheWorkToBeDoneOn[#1]#2% >{\processcommalist[#1]{\WeHaveToDo{#2}}} > > \def\WeHaveToDo#1#2{(#2: #1)} Thanks for the proposal. I included it into Wiki, but in my case the "\WeHaveToDo" was already defined and I needed it exactly in the form that Taco suggested (to call \OnlyStep[#1]{#2} with \OnSteps[1-3,5]{content} in t-rsteps module). > btw, nice thread for a wiki entry I added it to http://contextgarden.net/Inside_ConTeXt#Processing_lists_of_values. > >>>Is there also a possibility to define a command like > >>>\IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} > >> > >>There was not, but knowing Hans I trust that soon there will be :-). > > hm, well, it does rain outside, but ... Taco's solution already solved my problem, but I believe it would be nice to add some \processenumeratedlist (well, some better name should be given!) command to ConTeXt one day. That way it would be possible to process some commands like \filterpages[file.pdf][1,3,5] also with \filterpages[file.pdf][1-3,5,7-11] Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"?
Mojca Miklavec wrote: Taco Hoekwater wrote: Mojca Miklavec wrote: I would like to define a command, which would be called in the following way: \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} so that it would be equivalent to: \WeHaveToDo[monday]{tidy up} \WeHaveToDo[wednesday]{tidy up} \WeHaveToDo[thursday]{tidy up} I played a bit with different variants of \processcommalist, but I can't figure out how to use it in this particular case. The trick is to store the tidy up inside the processing command, like so: \def\WeHaveToDo[#1]#2{\message{(#1: #2)}} \def\TheBossWantsTheWorkToBeDoneOn[#1]#2% {\begingroup \def\processitem##1{\WeHaveToDo[##1]{#2}}% \processcommalist[#1]\processitem \endgroup } \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} Great, thanks Taco! It works. It seems easier than I thought, but I could have spent hours looking for the proper solution alone. Actually, there is an easier way to do this; just swap the arguments to WeHaveToDo: \def\TheBossWantsTheWorkToBeDoneOn[#1]#2% {\processcommalist[#1]{\WeHaveToDo{#2}}} \def\WeHaveToDo#1#2{(#2: #1)} \starttext \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} \stoptext btw, nice thread for a wiki entry I hope this will land in the t-rsteps module (\OnSteps[1,2,3,6]{...}). Is there also a possibility to define a command like \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} There was not, but knowing Hans I trust that soon there will be :-). hm, well, it does rain outside, but ... Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"? (corrected solution)
I have to reply to myself, because Mojca discovered an error in my example code. This: Taco Hoekwater wrote: \def\IHaveToDoTheTasks[#1]#2% {\begingroup \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% \uncompresslist[#1]% <= Yeah! \processcommacommand[\uncompressedlist]\processitem \endgroup } should have been: \def\IHaveToDoTheTasks[#1]#2% {\begingroup \uncompresslist[#1]% <= Yeah! (do this first!) \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% \processcommacommand[\uncompressedlist]\processitem \endgroup } Greetings again, Taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"?
Taco Hoekwater wrote: > Mojca Miklavec wrote: > > I would like to define a command, which would be called in the following > > way: > > \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} > > > > so that it would be equivalent to: > > \WeHaveToDo[monday]{tidy up} > > \WeHaveToDo[wednesday]{tidy up} > > \WeHaveToDo[thursday]{tidy up} > > > > I played a bit with different variants of \processcommalist, but I > > can't figure out how to use it in this particular case. > > The trick is to store the tidy up inside the processing command, > like so: > >\def\WeHaveToDo[#1]#2{\message{(#1: #2)}} > >\def\TheBossWantsTheWorkToBeDoneOn[#1]#2% > {\begingroup > \def\processitem##1{\WeHaveToDo[##1]{#2}}% > \processcommalist[#1]\processitem > \endgroup } > >\TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} Great, thanks Taco! It works. It seems easier than I thought, but I could have spent hours looking for the proper solution alone. I hope this will land in the t-rsteps module (\OnSteps[1,2,3,6]{...}). > > Is there also a possibility to define a command like > > \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} > > There was not, but knowing Hans I trust that soon there will be :-). :) > For now, here is my solution. > > [...] > > With these, you can do: > >\def\IHaveToDoTheTask[#1]#2{\message{(#1: #2)}} > >\def\IHaveToDoTheTasks[#1]#2% > {\begingroup > \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% > \uncompresslist[#1]% <= Yeah! > \processcommacommand[\uncompressedlist]\processitem > \endgroup } > > I hope you understand what I've done, but otherwise, feel > free to ask, of course. Well, my stomach needs some time to process the latter example. But if I write \def\IHaveToDoTheTask[#1]#2{\message{(#1: #2)}The task #1 has to be done #2.\crlf} \IHaveToDoTheTasks[1-3]{until tomorrow} nothing happens. Thanks again, Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] How to "\processcommalist"?
Mojca Miklavec wrote: I would like to define a command, which would be called in the following way: \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} so that it would be equivalent to: \WeHaveToDo[monday]{tidy up} \WeHaveToDo[wednesday]{tidy up} \WeHaveToDo[thursday]{tidy up} I played a bit with different variants of \processcommalist, but I can't figure out how to use it in this particular case. The trick is to store the tidy up inside the processing command, like so: \def\WeHaveToDo[#1]#2{\message{(#1: #2)}} \def\TheBossWantsTheWorkToBeDoneOn[#1]#2% {\begingroup \def\processitem##1{\WeHaveToDo[##1]{#2}}% \processcommalist[#1]\processitem \endgroup } \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} Is there also a possibility to define a command like \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} There was not, but knowing Hans I trust that soon there will be :-). For now, here is my solution. % a few auxiliary core macros are needed to uncompress the list. % % \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... % \def\apptomac#1#2% {\ifx#1\empty\def#1{#2}\else [EMAIL PROTECTED]@[EMAIL PROTECTED],#2}\fi} % the next macro does this: % % \itemwithdash<<9-11>>- => \dorecurse {<<1+11-9>>} % {\apptomac\uncompressedlist<<9-1+\recurselevel>>} % % (the 1+ and -1 are needed to solve a counter offset.) \def\itemwithdash#1-#2-% [EMAIL PROTECTED]@EA {\the\numexpr 1+#2-#1\relax}% [EMAIL PROTECTED]@[EMAIL PROTECTED] {\the\numexpr #1-1+\recurselevel\relax}}}% % top level. The result will be in \uncompressedlist \def\uncompresslist[#1]% {\def\uncompressedlist{}% \def\processitem##1% {\doifinstringelse{-}{##1} {\itemwithdash##1-} {\apptomac\uncompressedlist{##1}}}% \processcommalist[#1]\processitem } \protect % end support macros. With these, you can do: \def\IHaveToDoTheTask[#1]#2{\message{(#1: #2)}} \def\IHaveToDoTheTasks[#1]#2% {\begingroup \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% \uncompresslist[#1]% <= Yeah! \processcommacommand[\uncompressedlist]\processitem \endgroup } I hope you understand what I've done, but otherwise, feel free to ask, of course. Greetings, Taco ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
[NTG-context] How to "\processcommalist"?
I would like to define a command, which would be called in the following way: \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} so that it would be equivalent to: \WeHaveToDo[monday]{tidy up} \WeHaveToDo[wednesday]{tidy up} \WeHaveToDo[thursday]{tidy up} I played a bit with different variants of \processcommalist, but I can't figure out how to use it in this particular case. Is there also a possibility to define a command like \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} which would expand into \IHaveToDoTheTask[1]{until tomorrow} \IHaveToDoTheTask[2]{until tomorrow} \IHaveToDoTheTask[3]{until tomorrow} \IHaveToDoTheTask[4]{until tomorrow} \IHaveToDoTheTask[7]{until tomorrow} \IHaveToDoTheTask[9]{until tomorrow} \IHaveToDoTheTask[10]{until tomorrow} \IHaveToDoTheTask[11]{until tomorrow} ? Thanks for any suggestions, Mojca ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context