summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3seq.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-07 03:00:49 +0000
committerNorbert Preining <norbert@preining.info>2019-09-07 03:00:49 +0000
commit7345b8683c7cbeaedf53e992fda0b3fa6141084e (patch)
tree3246f6574e0921c2111b93b76720f54034238185 /macros/latex/contrib/l3kernel/l3seq.dtx
parentbd3ecfd29a422ad4d7f8f1e119ddc518494e567a (diff)
CTAN sync 201909070300
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3seq.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3seq.dtx46
1 files changed, 45 insertions, 1 deletions
diff --git a/macros/latex/contrib/l3kernel/l3seq.dtx b/macros/latex/contrib/l3kernel/l3seq.dtx
index 2a0083bd6a..91bb0784fa 100644
--- a/macros/latex/contrib/l3kernel/l3seq.dtx
+++ b/macros/latex/contrib/l3kernel/l3seq.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2019-08-25}
+% \date{Released 2019-09-05}
%
% \maketitle
%
@@ -498,6 +498,8 @@
% Applies \meta{function} to every \meta{item} stored in the
% \meta{sequence}. The \meta{function} will receive one argument for
% each iteration. The \meta{items} are returned from left to right.
+% To pass further arguments to the \meta{function}, see
+% \cs{seq_map_tokens:Nn}.
% The function \cs{seq_map_inline:Nn} is faster than
% \cs{seq_map_function:NN} for sequences with more than about~$10$
% items.
@@ -514,6 +516,23 @@
% The \meta{items} are returned from left to right.
% \end{function}
%
+% \begin{function}[rEXP, added = 2019-08-30]
+% {\seq_map_tokens:Nn, \seq_map_tokens:cn}
+% \begin{syntax}
+% \cs{seq_map_tokens:Nn} \meta{sequence} \Arg{code}
+% \end{syntax}
+% Analogue of \cs{seq_map_function:NN} which maps several tokens
+% instead of a single function. The \meta{code} receives each item in
+% the \meta{sequence} as two trailing brace groups. For instance,
+% \begin{verbatim}
+% \seq_map_tokens:Nn \l_my_seq { \prg_replicate:nn { 2 } }
+% \end{verbatim}
+% expands to twice each item in the \meta{sequence}: for each item in
+% |\l_my_seq| the function \cs{prg_replicate:nn} receives |2| and
+% \meta{item} as its two arguments. The function
+% \cs{seq_map_inline:Nn} is typically faster but is not expandable.
+% \end{function}
+%
% \begin{function}[updated = 2012-06-29]
% {
% \seq_map_variable:NNn, \seq_map_variable:Ncn,
@@ -1835,6 +1854,31 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\seq_map_tokens:Nn, \seq_map_tokens:cn}
+% \begin{macro}{\@@_map_tokens:nw}
+% This is based on the function mapping but using the same tricks as
+% described for \cs{prop_map_tokens:Nn}. The idea is to remove the leading
+% \cs{s_@@} and apply the tokens such that they are safe with the
+% break points, hence the \cs{use:n}.
+% \begin{macrocode}
+\cs_new:Npn \seq_map_tokens:Nn #1#2
+ {
+ \exp_last_unbraced:Nno
+ \use_i:nn { \@@_map_tokens:nw {#2} } #1
+ \prg_break: \@@_item:n { } \prg_break_point:
+ \prg_break_point:Nn \seq_map_break: { }
+ }
+\cs_generate_variant:Nn \seq_map_tokens:Nn { c }
+\cs_new:Npn \@@_map_tokens:nw #1#2 \@@_item:n #3
+ {
+ #2
+ \use:n {#1} {#3}
+ \@@_map_tokens:nw {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}
% {
% \seq_map_variable:NNn, \seq_map_variable:Ncn,