diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3clist.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expl3/l3clist.dtx | 126 |
1 files changed, 29 insertions, 97 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3clist.dtx b/Master/texmf-dist/source/latex/expl3/l3clist.dtx index 4ae2d84d587..c3167477819 100644 --- a/Master/texmf-dist/source/latex/expl3/l3clist.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3clist.dtx @@ -36,7 +36,7 @@ \RequirePackage{l3names} %</driver|package> %\fi -\GetIdInfo$Id: l3clist.dtx 1878 2010-03-29 07:15:02Z joseph $ +\GetIdInfo$Id: l3clist.dtx 1992 2010-08-04 20:41:40Z joseph $ {L3 Experimental comma separated lists} %\iffalse %<*driver> @@ -875,103 +875,35 @@ % % \subsection{Mapping} % -% \begin{macro}{\clist_map_function:NN} -% \begin{macro}{\clist_map_function:cN} -% \begin{macro}{\clist_map_function:nN} -% |\clist_map_function:NN| \meta{comma-list} \meta{cmd} applies \meta{cmd} to each -% element of \meta{comma-list}, from left to right. +%\begin{macro}{\clist_map_function:NN} +%\begin{macro}{\clist_map_function:Nc} +%\begin{macro}{\clist_map_function:cN} +%\begin{macro}{\clist_map_function:cc} +%\begin{macro}{\clist_map_function:nN} +%\begin{macro}{\clist_map_function:nc} +%\begin{macro}{\clist_map_inline:Nn} +%\begin{macro}{\clist_map_inline:cn} +%\begin{macro}{\clist_map_inline:nn} +%\begin{macro}{\clist_map_break:} +% Using the above creating the comma mappings is easy.. % \begin{macrocode} -\cs_new_nopar:Npn \clist_map_function:NN #1#2 { - \clist_if_empty:NF #1 { - \exp_after:wN \clist_map_function_aux:Nw - \exp_after:wN #2 #1 , \q_recursion_tail , \q_recursion_stop - } -} -\cs_generate_variant:Nn \clist_map_function:NN {cN} -% \end{macrocode} -% \begin{macrocode} -\cs_new:Npn \clist_map_function:nN #1#2 { - \tl_if_blank:nF {#1} { - \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \q_recursion_stop - } -} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}[aux]{\clist_map_function_aux:Nw} -% The general loop. Tests if we hit the first stop marker and exits if -% we did. If we didn't, place the function "#1" in front of the -% element "#2", which is surrounded by braces. -% \begin{macrocode} -\cs_new:Npn \clist_map_function_aux:Nw #1#2,{ - \quark_if_recursion_tail_stop:n{#2} - #1{#2} - \clist_map_function_aux:Nw #1 -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\clist_map_break:} -% The break statement is easy. Same as in other modules, gobble -% everything up to the special recursion stop marker. -% \begin{macrocode} -\cs_new_eq:NN \clist_map_break: \use_none_delimit_by_q_recursion_stop:w -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\clist_map_inline:Nn} -% \begin{macro}{\clist_map_inline:cn} -% \begin{macro}{\clist_map_inline:nn} -% The inline type is faster but not expandable. In order to make it -% nestable, we use a counter to keep track of the nesting level so -% that all of the functions called have distict names. A simpler -% approach would of course be to use grouping and thus the save -% stack but then you lose the ability to do things locally. -% -% A funny little thing occured in one document: The command setting -% up the first call of |\clist_map_inline:Nn| was used in a tabular -% cell and the inline code used |\\| so the loop broke as soon as -% this happened. Lesson to be learned from this: If you wish to have -% group like structure but not using the groupings of \TeX, then do -% every operation globally. -% \begin{macrocode} -\int_new:N \g_clist_inline_level_int -\cs_new_protected:Npn \clist_map_inline:Nn #1#2 { - \clist_if_empty:NF #1 { - \int_gincr:N \g_clist_inline_level_int - \cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n} - ##1{#2} -% \end{macrocode} -% It is a lot more efficient to carry over -% the special function rather than constructing the same csname over -% and over again, so we just do it once. We reuse -% |\clist_map_function_aux:Nw| for the actual loop. -% \begin{macrocode} - \exp_last_unbraced:NcV \clist_map_function_aux:Nw - {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n} - #1 , \q_recursion_tail , \q_recursion_stop - \int_gdecr:N \g_clist_inline_level_int - } -} -\cs_generate_variant:Nn \clist_map_inline:Nn {c} -\cs_new_protected:Npn \clist_map_inline:nn #1#2 { - \tl_if_empty:nF {#1} { - \int_gincr:N \g_clist_inline_level_int - \cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n} - ##1{#2} - \exp_args:Nc \clist_map_function_aux:Nw - {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n} - #1 , \q_recursion_tail , \q_recursion_stop - \int_gdecr:N \g_clist_inline_level_int - } -} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% +\prg_new_map_functions:Nn , { clist } +\cs_generate_variant:Nn \clist_map_function:NN { Nc } +\cs_generate_variant:Nn \clist_map_function:NN { c } +\cs_generate_variant:Nn \clist_map_function:NN { cc } +\cs_generate_variant:Nn \clist_map_inline:Nn { c } +\cs_generate_variant:Nn \clist_map_inline:Nn { nc } +% \end{macrocode} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} % % \begin{macro}{\clist_map_variable:nNn} % \begin{macro}{\clist_map_variable:NNn} |