[latex3-commits] [git/LaTeX3-latex3-latex3] master: Document and test \seq_map_tokens:Nn (4d7a59910)

Bruno Le Floch bruno at le-floch.fr
Fri Aug 30 20:50:45 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/4d7a59910a66f7457301d16ae4e42e114d4fb112

>---------------------------------------------------------------

commit 4d7a59910a66f7457301d16ae4e42e114d4fb112
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Fri Aug 30 20:50:45 2019 +0200

    Document and test \seq_map_tokens:Nn


>---------------------------------------------------------------

4d7a59910a66f7457301d16ae4e42e114d4fb112
 l3kernel/l3prop.dtx             |  2 ++
 l3kernel/l3seq.dtx              | 21 ++++++++++++++++++++-
 l3kernel/testfiles/m3seq008.lvt | 15 ++++++++++++++-
 l3kernel/testfiles/m3seq008.tlg | 19 +++++++++++++++++++
 4 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/l3kernel/l3prop.dtx b/l3kernel/l3prop.dtx
index 0ecf12f3d..f9761445c 100644
--- a/l3kernel/l3prop.dtx
+++ b/l3kernel/l3prop.dtx
@@ -353,6 +353,8 @@
 %   each iteration: the \meta{key} and associated \meta{value}.
 %   The order in which \meta{entries} are returned is not defined and
 %   should not be relied upon.
+%   To pass further arguments to the \meta{function}, see
+%   \cs{prop_map_tokens:Nn}.
 % \end{function}
 %
 % \begin{function}[updated = 2013-01-08]
diff --git a/l3kernel/l3seq.dtx b/l3kernel/l3seq.dtx
index dcb435498..494dba0be 100644
--- a/l3kernel/l3seq.dtx
+++ b/l3kernel/l3seq.dtx
@@ -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,
@@ -1839,7 +1858,7 @@
 % \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{@@_item:n} and apply the tokens such that they are safe with the
+%   \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
diff --git a/l3kernel/testfiles/m3seq008.lvt b/l3kernel/testfiles/m3seq008.lvt
index af4a9bc2c..0f83eea7d 100644
--- a/l3kernel/testfiles/m3seq008.lvt
+++ b/l3kernel/testfiles/m3seq008.lvt
@@ -1,5 +1,5 @@
 %
-% Copyright (C) 2014,2018 LaTeX3 Project
+% Copyright (C) 2014,2018,2019 LaTeX3 Project
 %
 
 \documentclass{minimal}
@@ -79,4 +79,17 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\TEST { seq_map_tokens:Nn }
+  {
+    \seq_map_tokens:Nn \l_tmpa_seq { \test:nn { A } }
+    \SEPARATOR
+    \seq_map_tokens:Nn \l_tmpb_seq { \test:nn { A } }
+    \SEPARATOR
+    \seq_map_tokens:Nn \g_tmpa_seq { \test:nn { A } }
+    \SEPARATOR
+    \seq_map_tokens:Nn \g_tmpb_seq { \test:nn { A } }
+  }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \END
diff --git a/l3kernel/testfiles/m3seq008.tlg b/l3kernel/testfiles/m3seq008.tlg
index e6c84529d..fe449c64e 100644
--- a/l3kernel/testfiles/m3seq008.tlg
+++ b/l3kernel/testfiles/m3seq008.tlg
@@ -60,3 +60,22 @@ TEST 3: seq_indexed_map_inline:Nn
 "6":"\a "
 ============================================================
 ============================================================
+============================================================
+TEST 4: seq_map_tokens:Nn
+============================================================
+"A":"c"
+"A":"b"
+"A":"a"
+============================================================
+"A":"{C}"
+"A":" B"
+"A":"A "
+============================================================
+"A":"\f "
+"A":"\e "
+"A":"\d "
+"A":"\c "
+"A":"\b "
+"A":"\a "
+============================================================
+============================================================





More information about the latex3-commits mailing list