[latex3-commits] [git/LaTeX3-latex3-latex3] main: Implement \prop_concat:NNN (aa6280a58)

Bruno Le Floch blflatex at gmail.com
Sun May 16 23:44:23 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/aa6280a586f0f6bfdf1b5136509778ab08fb2b4e

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

commit aa6280a586f0f6bfdf1b5136509778ab08fb2b4e
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Sun May 16 23:30:07 2021 +0200

    Implement \prop_concat:NNN


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

aa6280a586f0f6bfdf1b5136509778ab08fb2b4e
 l3kernel/CHANGELOG.md            |  1 +
 l3kernel/l3prop.dtx              | 42 +++++++++++++++++++++++++++++++++++++++-
 l3kernel/testfiles/m3prop005.lvt | 14 ++++++++++++++
 l3kernel/testfiles/m3prop005.tlg | 11 +++++++++++
 4 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 24939c7ac..44640d90b 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Added
 - `\sys_timer:`
+- `\prop_concat:NNN`
 - Functions to show and log various datatypes (issue #241):
   `\coffin_show:Nnn`, `\coffin_show:N`, `\coffin_log:Nnn`, `\coffin_log:N`,
   `\color_log:n`, `\group_show_list:`, `\group_log_list:`,
diff --git a/l3kernel/l3prop.dtx b/l3kernel/l3prop.dtx
index e57d9ee23..0e6cabd15 100644
--- a/l3kernel/l3prop.dtx
+++ b/l3kernel/l3prop.dtx
@@ -191,6 +191,21 @@
 %   \cs{prop_put:Nnn}.
 % \end{function}
 %
+% \begin{function}[added = 2021-05-16]
+%   {
+%     \prop_concat:NNN,  \prop_concat:ccc,
+%     \prop_gconcat:NNN, \prop_gconcat:ccc
+%   }
+%   \begin{syntax}
+%     \cs{prop_concat:NNN} \meta{prop~var_1} \meta{prop~var_2} \meta{prop~var_3}
+%   \end{syntax}
+%   Combines the key--value pairs of \meta{prop~var_2} and
+%   \meta{prop~var_3}, and saves the result in \meta{prop~var_1}.  If a
+%   key appears in both \meta{prop~var_2} and \meta{prop~var_3} then the
+%   last value, namely the value in \meta{prop~var_3} is kept while the
+%   other is discarded.
+% \end{function}
+%
 % \section{Recovering values from property lists}
 %
 % \begin{function}[updated = 2011-08-28]
@@ -727,12 +742,37 @@
 % \end{variable}
 %
 % \begin{variable}{\l_@@_internal_prop}
-%   Property list used by \cs{prop_set_from_keyval:Nn} and others.
+%   Property list used by \cs{prop_concat:NNN},
+%   \cs{prop_set_from_keyval:Nn} and others.
 %    \begin{macrocode}
 \prop_new:N \l_@@_internal_prop
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{macro}
+%   {
+%     \prop_concat:NNN, \prop_concat:ccc,
+%     \prop_gconcat:NNN, \prop_gconcat:ccc, \@@_concat:NNNN
+%   }
+%   Combine two property lists.  We cannot use a simple
+%   \cs{tl_concat:NNN} because there may be some duplicate keys between
+%   the two property lists.
+%    \begin{macrocode}
+\cs_new_protected:Npn \prop_concat:NNN
+  { \@@_concat:NNNN \prop_set_eq:NN }
+\cs_generate_variant:Nn \prop_concat:NNN { ccc }
+\cs_new_protected:Npn \prop_gconcat:NNN
+  { \@@_concat:NNNN \prop_gset_eq:NN }
+\cs_generate_variant:Nn \prop_gconcat:NNN { ccc }
+\cs_new_protected:Npn \@@_concat:NNNN #1#2#3#4
+  {
+    \prop_set_eq:NN \l_@@_internal_prop #3
+    \prop_map_tokens:Nn #4 { \prop_put:Nnn \l_@@_internal_prop }
+    #1 #2 \l_@@_internal_prop
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\prop_set_from_keyval:Nn, \prop_set_from_keyval:cn}
 % \begin{macro}{\prop_gset_from_keyval:Nn, \prop_gset_from_keyval:cn}
 % \begin{macro}{\prop_const_from_keyval:Nn, \prop_const_from_keyval:cn}
diff --git a/l3kernel/testfiles/m3prop005.lvt b/l3kernel/testfiles/m3prop005.lvt
index 237892d9f..db76da88e 100644
--- a/l3kernel/testfiles/m3prop005.lvt
+++ b/l3kernel/testfiles/m3prop005.lvt
@@ -45,5 +45,19 @@
     \prop_log:N \c_B_prop
   }
 
+\TEST { prop_concat }
+  {
+    \prop_set_from_keyval:Nn \l_tmpa_prop
+      { \a = b , ~ \c ~ = ~ { ~ \d = e ~ } , , = , { = } = , ~ { } ~ = { , } , }
+    \prop_set_eq:NN \l_tmpb_prop \l_tmpa_prop
+    \prop_concat:NNN \l_tmpa_prop \l_tmpa_prop \l_tmpa_prop
+    \tl_if_eq:NNTF \l_tmpa_prop \l_tmpb_prop { \TRUE } { \ERROR }
+    %
+    \prop_gset_from_keyval:Nn \g_tmpa_prop
+      { x = y , , \a = c , ~ \c ~ = ~ { ~ \D = E ~ } , , = ? , }
+    \prop_gconcat:ccc { g_tmpa_prop } { l_tmpa_prop } { g_tmpa_prop }
+    \prop_log:N \g_tmpa_prop
+  }
+
 \END
 
diff --git a/l3kernel/testfiles/m3prop005.tlg b/l3kernel/testfiles/m3prop005.tlg
index d64191f91..75784f3d4 100644
--- a/l3kernel/testfiles/m3prop005.tlg
+++ b/l3kernel/testfiles/m3prop005.tlg
@@ -95,3 +95,14 @@ Defining \c_B_prop on line ...
 The property list \c_B_prop is empty
 > .
 ============================================================
+============================================================
+TEST 3: prop_concat
+============================================================
+TRUE
+The property list \g_tmpa_prop contains the pairs (without outer braces):
+>  {\a }  =>  {c}
+>  {\c }  =>  { \D =E }
+>  {}  =>  {?}
+>  {=}  =>  {}
+>  {x}  =>  {y}.
+============================================================





More information about the latex3-commits mailing list.