diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3seq.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3seq.dtx | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx index 7b2121719de..40d829f96cb 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-06-03} +% \date{Released 2020-06-18} % % \maketitle % @@ -578,6 +578,26 @@ % \meta{items} are returned from left to right. % \end{function} % +% \begin{function}[rEXP,added = 2018-05-03]{\seq_map_indexed_function:NN} +% \begin{syntax} +% \cs{seq_map_indexed_function:NN} \meta{seq~var} \meta{function} +% \end{syntax} +% Applies \meta{function} to every entry in the \meta{sequence +% variable}. The \meta{function} should have signature |:nn|. It +% receives two arguments for each iteration: the \meta{index} (namely +% |1| for the first entry, then |2| and so on) and the \meta{item}. +% \end{function} +% +% \begin{function}[added = 2018-05-03]{\seq_map_indexed_inline:Nn} +% \begin{syntax} +% \cs{seq_map_indexed_inline:Nn} \meta{seq~var} \Arg{inline function} +% \end{syntax} +% Applies \meta{inline function} to every entry in the \meta{sequence +% variable}. The \meta{inline function} should consist of code which +% receives the \meta{index} (namely |1| for the first entry, then |2| +% and so on) as~|#1| and the \meta{item} as~|#2|. +% \end{function} +% % \begin{function}[rEXP, updated = 2012-06-29]{\seq_map_break:} % \begin{syntax} % \cs{seq_map_break:} @@ -2018,6 +2038,50 @@ % \end{macrocode} % \end{macro} % +% \begin{macro} +% { +% \seq_map_indexed_function:NN, \seq_map_indexed_inline:Nn, +% \@@_map_indexed:nNN, \@@_map_indexed:Nw +% } +% Similar to \cs{seq_map_function:NN} but we keep track of the item +% index as a |;|-delimited argument of \cs{@@_map_indexed:Nw}. +% \begin{macrocode} +\cs_new:Npn \seq_map_indexed_function:NN #1#2 + { + \@@_map_indexed:NN #1#2 + \prg_break_point:Nn \seq_map_break: { } + } +\cs_new_protected:Npn \seq_map_indexed_inline:Nn #1#2 + { + \int_gincr:N \g__kernel_prg_map_int + \cs_gset_protected:cpn + { @@_map_ \int_use:N \g__kernel_prg_map_int :w } ##1##2 {#2} + \exp_args:NNc \@@_map_indexed:NN #1 + { @@_map_ \int_use:N \g__kernel_prg_map_int :w } + \prg_break_point:Nn \seq_map_break: + { \int_gdecr:N \g__kernel_prg_map_int } + } +\cs_new:Npn \@@_map_indexed:NN #1#2 + { + \exp_after:wN \@@_map_indexed:Nw + \exp_after:wN #2 + \int_value:w 1 + \exp_after:wN \use_i:nn + \exp_after:wN ; + #1 + \prg_break: \@@_item:n { } \prg_break_point: + } +\cs_new:Npn \@@_map_indexed:Nw #1#2 ; #3 \@@_item:n #4 + { + #3 + #1 {#2} {#4} + \exp_after:wN \@@_map_indexed:Nw + \exp_after:wN #1 + \int_value:w \int_eval:w 1 + #2 ; + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\seq_count:N, \seq_count:c} % \begin{macro}{\@@_count:w, \@@_count_end:w} % Since counting the items in a sequence is quite common, we optimize |