[latex3-commits] [l3svn] r6688 - Add \prop_count:N as requested by D.Bitouze (fixes #293)

noreply at latex-project.org noreply at latex-project.org
Fri Aug 19 21:21:48 CEST 2016


Author: bruno
Date: 2016-08-19 21:21:48 +0200 (Fri, 19 Aug 2016)
New Revision: 6688

Modified:
   trunk/l3kernel/l3candidates.dtx
   trunk/l3kernel/testfiles/m3expl001.luatex.tlg
   trunk/l3kernel/testfiles/m3expl001.ptex.tlg
   trunk/l3kernel/testfiles/m3expl001.tlg
   trunk/l3kernel/testfiles/m3expl001.uptex.tlg
   trunk/l3kernel/testfiles/m3expl001.xetex.tlg
   trunk/l3kernel/testfiles/m3expl003.luatex.tlg
   trunk/l3kernel/testfiles/m3expl003.ptex.tlg
   trunk/l3kernel/testfiles/m3expl003.tlg
   trunk/l3kernel/testfiles/m3expl003.uptex.tlg
   trunk/l3kernel/testfiles/m3expl003.xetex.tlg
   trunk/l3kernel/testfiles/m3prop003.lvt
   trunk/l3kernel/testfiles/m3prop003.tlg
Log:
Add \prop_count:N as requested by D.Bitouze (fixes #293)

That's an easy candidate function to add, and it makes sense since we can
already count tl, clist, seq.


Modified: trunk/l3kernel/l3candidates.dtx
===================================================================
--- trunk/l3kernel/l3candidates.dtx	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/l3candidates.dtx	2016-08-19 19:21:48 UTC (rev 6688)
@@ -640,6 +640,14 @@
 %
 % \section{Additions to \pkg{l3prop}}
 %
+% \begin{function}[EXP]{\prop_count:N, \prop_count:c}
+%   \begin{syntax}
+%     \cs{prop_count:N} \meta{property list}
+%   \end{syntax}
+%   Leaves the number of key--value pairs in the \meta{property list} in
+%   the input stream as an \meta{integer denotation}.
+% \end{function}
+%
 % \begin{function}[rEXP]
 %   {\prop_map_tokens:Nn, \prop_map_tokens:cn}
 %   \begin{syntax}
@@ -2571,6 +2579,27 @@
 %<@@=prop>
 %    \end{macrocode}
 %
+% \begin{macro}[EXP]{\prop_count:N, \prop_count:c}
+% \begin{macro}[aux,EXP]{\@@_count:nn}
+%   Counting the key--value pairs in a property list is done using the
+%   same approach as for other count functions: turn each entry into a
+%   \texttt{+1} then use integer evaluation to actually do the
+%   mathematics.
+%    \begin{macrocode}
+\cs_new:Npn \prop_count:N #1
+  {
+    \int_eval:n
+      {
+        \c_zero
+        \prop_map_function:NN #1 \@@_count:nn
+      }
+  }
+\cs_new:Npn \@@_count:nn #1#2 { + \c_one }
+\cs_generate_variant:Nn \prop_count:N { c }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}[rEXP]{\prop_map_tokens:Nn, \prop_map_tokens:cn}
 % \begin{macro}[aux]{\@@_map_tokens:nwwn}
 %   The mapping is very similar to \cs{prop_map_function:NN}.  It grabs

Modified: trunk/l3kernel/testfiles/m3expl001.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4578,6 +4578,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4569,6 +4569,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl001.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4569,6 +4569,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4569,6 +4569,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4576,6 +4576,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4579,6 +4579,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4570,6 +4570,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl003.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4570,6 +4570,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4570,6 +4570,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -4577,6 +4577,9 @@
 Defining \bool_log:N on line ...
 Defining \bool_log:n on line ...
 Defining \bool_log:c on line ...
+Defining \prop_count:N on line ...
+Defining \__prop_count:nn on line ...
+Defining \prop_count:c on line ...
 Defining \prop_map_tokens:Nn on line ...
 Defining \__prop_map_tokens:nwwn on line ...
 Defining \prop_map_tokens:cn on line ...

Modified: trunk/l3kernel/testfiles/m3prop003.lvt
===================================================================
--- trunk/l3kernel/testfiles/m3prop003.lvt	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3prop003.lvt	2016-08-19 19:21:48 UTC (rev 6688)
@@ -164,5 +164,8 @@
     | \prop_item:Nn \l_a_prop { xx } |
   }
 
+\TESTEXP { count }
+  { \prop_count:N \l_a_prop | \prop_count:N \c_empty_prop }
+
 \END
 

Modified: trunk/l3kernel/testfiles/m3prop003.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3prop003.tlg	2016-08-19 19:10:14 UTC (rev 6687)
+++ trunk/l3kernel/testfiles/m3prop003.tlg	2016-08-19 19:21:48 UTC (rev 6688)
@@ -87,3 +87,8 @@
 |##testb\par |
 ||
 ============================================================
+============================================================
+TEST 9: count
+============================================================
+6|0
+============================================================



More information about the latex3-commits mailing list