[latex3-commits] [git/LaTeX3-latex3-latex3] master: Rework \prop_rand_key_value:N (c712daf)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Mar 26 10:57:44 CEST 2018


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

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

commit c712dafab8032cdeb63746f4bbbfada442007a12
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Mar 26 09:57:44 2018 +0100

    Rework \prop_rand_key_value:N
    
    The older version was set up for a more flexible ouput.


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

c712dafab8032cdeb63746f4bbbfada442007a12
 l3kernel/l3candidates.dtx               |   41 +++++++++++++++++--------------
 l3kernel/testfiles/m3expl001.luatex.tlg |    7 +++---
 l3kernel/testfiles/m3expl001.ptex.tlg   |    7 +++---
 l3kernel/testfiles/m3expl001.tlg        |    7 +++---
 l3kernel/testfiles/m3expl001.uptex.tlg  |    7 +++---
 l3kernel/testfiles/m3expl001.xetex.tlg  |    7 +++---
 l3kernel/testfiles/m3expl003.luatex.tlg |    7 +++---
 l3kernel/testfiles/m3expl003.ptex.tlg   |    7 +++---
 l3kernel/testfiles/m3expl003.tlg        |    7 +++---
 l3kernel/testfiles/m3expl003.uptex.tlg  |    7 +++---
 l3kernel/testfiles/m3expl003.xetex.tlg  |    7 +++---
 11 files changed, 63 insertions(+), 48 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 6ef1173..2ea26f5 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -2140,36 +2140,41 @@
 %
 % \begin{macro}[EXP]
 %   {\prop_rand_key_value:N, \prop_rand_key_value:c}
-% \begin{macro}[EXP]{\@@_rand:NN, \@@_rand_item:Nw}
+% \begin{macro}[EXP]{\@@_rand_key_item:nN, \@@_rand_key_item:fN}
+% \begin{macro}[EXP]{\@@_rand_key_item:nn}
+% \begin{macro}[EXP]{\@@_rand_item:w}
 %   Contrarily to |clist|, |seq| and |tl|, there is no function to get
 %   an item of a |prop| given an integer between $1$ and the number of
 %   items, so we write the appropriate code.  There is no bounds
-%   checking because \cs{int_rand:nn} is always within bounds.  At the
-%   end, leave either the key |#3| or the value |#4| in the input
-%   stream.
+%   checking because \cs{int_rand:nn} is always within bounds.
 %    \begin{macrocode}
-\cs_new:Npn \prop_rand_key_value:N { \@@_rand:NN \@@_rand:nNn }
-\cs_new:Npn \@@_rand:nNn #1#2#3 { \exp_not:n { {#1} {#3} } }
-\cs_new:Npn \@@_rand:NN #1#2
+\cs_new:Npn \prop_rand_key_value:N #1
   {
-    \prop_if_empty:NF #2
+    \prop_if_empty:NF #1
       {
-        \exp_after:wN \@@_rand_item:Nw \exp_after:wN #1
-        \__int_value:w \int_rand:nn { 1 } { \prop_count:N #2 } #2
-        \q_stop
+        \@@_rand_key_item:fN
+          { \int_eval:n { \int_rand:nn { 1 } { \prop_count:N #1 } } }
+          #1
       }
   }
-\cs_new:Npn \@@_rand_item:Nw #1#2 \s_@@ \@@_pair:wn #3 \s_@@ #4
-  {
-    \int_compare:nNnF {#2} > 1
-      { \use_i_delimit_by_q_stop:nw { #1 {#3} \exp_not:n {#4} } }
-    \exp_after:wN \@@_rand_item:Nw \exp_after:wN #1
-    \__int_value:w \int_eval:n { #2 - 1 } \s_@@
-  }
 \cs_generate_variant:Nn \prop_rand_key_value:N { c }
+\cs_new:Npn \@@_rand_key_item:nN #1#2
+  { \exp_after:wN \@@_rand_key_item:nn \exp_after:wN {#2} {#1} }
+\cs_generate_variant:Nn \@@_rand_key_item:nN { f }
+\cs_new:Npn \@@_rand_key_item:nn #1#2
+  { \@@_rand_item:w #2 #1 \q_stop }
+\cs_new:Npn \@@_rand_item:w #1 \s_@@ \@@_pair:wn #2 \s_@@ #3
+  {
+    \int_compare:nNnF {#1} > 1
+      { \use_i_delimit_by_q_stop:nw { \exp_not:n { {#2} {#3} } } }
+    \exp_after:wN \@@_rand_item:w
+    \__int_value:w \int_eval:n { #1 - 1 } \s_@@
+  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \subsection{Additions to \pkg{l3seq}}
 %
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 232b5aa..3650131 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5774,10 +5774,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 29d2581..2ed915c 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5713,10 +5713,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index fdbf6ce..a99ca91 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5713,10 +5713,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 4ad8eea..69716b2 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5711,10 +5711,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 37e6df5..28daa39 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5746,10 +5746,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 232b5aa..3650131 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5774,10 +5774,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 29d2581..2ed915c 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5713,10 +5713,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index fdbf6ce..a99ca91 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5713,10 +5713,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 4ad8eea..69716b2 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5711,10 +5711,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 37e6df5..28daa39 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5746,10 +5746,11 @@ Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...
 Defining \prop_rand_key_value:N on line ...
-Defining \__prop_rand:nNn on line ...
-Defining \__prop_rand:NN on line ...
-Defining \__prop_rand_item:Nw on line ...
 Defining \prop_rand_key_value:c on line ...
+Defining \__prop_rand_key_item:nN on line ...
+Defining \__prop_rand_key_item:fN on line ...
+Defining \__prop_rand_key_item:nn on line ...
+Defining \__prop_rand_item:w on line ...
 Defining \seq_mapthread_function:NNN on line ...
 Defining \__seq_mapthread_function:wNN on line ...
 Defining \__seq_mapthread_function:wNw on line ...





More information about the latex3-commits mailing list