[latex3-commits] [git/LaTeX3-latex3-latex3] master: Also add int_step_variable shorthands (see #454) (1850670)

Bruno Le Floch bruno at le-floch.fr
Mon Apr 23 04:27:34 CEST 2018


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

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

commit 1850670d990a4ab6323434b7292f6ca6008a1f3b
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sun Apr 22 22:25:33 2018 -0400

    Also add int_step_variable shorthands (see #454)


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

1850670d990a4ab6323434b7292f6ca6008a1f3b
 l3kernel/l3int.dtx                      |   46 +++++++++++++++++--------------
 l3kernel/testfiles/m3expl001.luatex.tlg |    6 ++--
 l3kernel/testfiles/m3expl001.ptex.tlg   |    6 ++--
 l3kernel/testfiles/m3expl001.tlg        |    6 ++--
 l3kernel/testfiles/m3expl001.uptex.tlg  |    6 ++--
 l3kernel/testfiles/m3expl001.xetex.tlg  |    6 ++--
 l3kernel/testfiles/m3expl003.luatex.tlg |    6 ++--
 l3kernel/testfiles/m3expl003.ptex.tlg   |    6 ++--
 l3kernel/testfiles/m3expl003.tlg        |    6 ++--
 l3kernel/testfiles/m3expl003.uptex.tlg  |    6 ++--
 l3kernel/testfiles/m3expl003.xetex.tlg  |    6 ++--
 l3kernel/testfiles/m3int003.lvt         |   20 +++++++++++++-
 l3kernel/testfiles/m3int003.tlg         |   23 ++++++++++++++++
 13 files changed, 108 insertions(+), 41 deletions(-)

diff --git a/l3kernel/l3int.dtx b/l3kernel/l3int.dtx
index eb1b4ad..9f82b3b 100644
--- a/l3kernel/l3int.dtx
+++ b/l3kernel/l3int.dtx
@@ -493,7 +493,7 @@
 % \section{Integer step functions}
 %
 % \begin{function}[added = 2012-06-04, updated = 2018-04-22, rEXP]
-%   {\int_step_function:nnnN}
+%   {\int_step_function:nN, \int_step_function:nnN, \int_step_function:nnnN}
 %   \begin{syntax}
 %     \cs{int_step_function:nN} \Arg{final value} \meta{function}
 %     \cs{int_step_function:nnN} \Arg{initial value} \Arg{final value} \meta{function}
@@ -529,7 +529,7 @@
 % \end{function}
 %
 % \begin{function}[added = 2012-06-04, updated = 2018-04-22]
-%   {\int_step_inline:nnnn}
+%   {\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn}
 %   \begin{syntax}
 %     \cs{int_step_inline:nn} \Arg{final value} \Arg{code}
 %     \cs{int_step_inline:nnn} \Arg{initial value} \Arg{final value} \Arg{code}
@@ -549,11 +549,12 @@
 %   $1$. These functions are provided as simple short-cuts for code clarity.
 % \end{function}
 %
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30]
-%   {\int_step_variable:nnnNn}
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22]
+%   {\int_step_variable:nnn, \int_step_variable:nnnn, \int_step_variable:nnnnn}
 %   \begin{syntax}
-%     \cs{int_step_variable:nnnNn} \\
-%     ~~\Arg{initial value} \Arg{step} \Arg{final value} \meta{tl~var} \Arg{code}
+%     \cs{int_step_variable:nNn} \Arg{final value} \meta{tl~var} \Arg{code}
+%     \cs{int_step_variable:nnNn} \Arg{initial value} \Arg{final value} \meta{tl~var} \Arg{code}
+%     \cs{int_step_variable:nnnNn} \Arg{initial value} \Arg{step} \Arg{final value} \meta{tl~var} \Arg{code}
 %   \end{syntax}
 %   This function first evaluates the \meta{initial value}, \meta{step}
 %   and \meta{final value}, all of which should be integer expressions.
@@ -562,6 +563,11 @@
 %   \meta{value}), the \meta{code} is inserted into the input stream,
 %   with the \meta{tl~var} defined as the current \meta{value}.  Thus
 %   the \meta{code} should make use of the \meta{tl~var}.
+%
+%   The functions \cs{int_step_variable:nNn} and \cs{int_step_variable:nnNn}
+%   both use a fixed \meta{step} of $1$, and in the case of
+%   \cs{int_step_variable:nNn} the \meta{initial value} is also fixed as
+%   $1$. These functions are provided as simple short-cuts for code clarity.
 % \end{function}
 %
 % \section{Formatting integers}
@@ -1837,22 +1843,20 @@
           #1 { \int_eval:n { #2 + #3 } } {#3} {#4} #5
       }
   }
-\cs_new:Npn \int_step_function:nN #1#2
-  { \int_step_function:nnnN { 1 } { 1 } {#1} #2 }
-\cs_new:Npn \int_step_function:nnN #1#2#3
-  { \int_step_function:nnnN {#1} { 1 } {#2} #3 }
+\cs_new:Npn \int_step_function:nN
+  { \int_step_function:nnnN { 1 } { 1 } }
+\cs_new:Npn \int_step_function:nnN #1
+  { \int_step_function:nnnN {#1} { 1 } }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\int_step_inline:nnnn}
-% \begin{macro}{\int_step_variable:nnnNn}
+% \begin{macro}{\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn}
+% \begin{macro}{\int_step_variable:nNn, \int_step_variable:nnNn, \int_step_variable:nnnNn}
 % \UnitTested
 % \begin{macro}{\@@_step:NNnnnn}
-% \begin{macro}{\int_step_inline:nN}
-% \begin{macro}{\int_step_inline:nnN}
 %   The approach here is to build a function, with a global integer
 %   required to make the nesting safe (as seen in other in line
 %   functions), and map that function using \cs{int_step_function:nnnN}.
@@ -1862,6 +1866,10 @@
 %   \cs{scan_stop:}, so that no breaking function recognizes this break
 %   point as its own.
 %    \begin{macrocode}
+\cs_new_protected:Npn \int_step_inline:nn
+  { \int_step_inline:nnnn { 1 } { 1 } }
+\cs_new_protected:Npn \int_step_inline:nnn #1
+  { \int_step_inline:nnnn {#1} { 1 } }
 \cs_new_protected:Npn \int_step_inline:nnnn
   {
     \int_gincr:N \g__kernel_prg_map_int
@@ -1869,6 +1877,10 @@
       \cs_gset_protected:Npn
       { @@_map_ \int_use:N \g__kernel_prg_map_int :w }
   }
+\cs_new_protected:Npn \int_step_variable:nNn
+  { \int_step_variable:nnnNn { 1 } { 1 } }
+\cs_new_protected:Npn \int_step_variable:nnNn #1
+  { \int_step_variable:nnnNn {#1} { 1 } }
 \cs_new_protected:Npn \int_step_variable:nnnNn #1#2#3#4#5
   {
     \int_gincr:N \g__kernel_prg_map_int
@@ -1887,16 +1899,10 @@
     \int_step_function:nnnN {#3} {#4} {#5} #2
     \prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__kernel_prg_map_int }
   }
-\cs_new_protected:Npn \int_step_inline:nn #1#2
-  { \int_step_inline:nnnn { 1 } { 1 } {#1} #2 }
-\cs_new_protected:Npn \int_step_inline:nnn #1#2#3
-  { \int_step_inline:nnnn {#1} { 1 } {#2} #3 }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
-% \end{macro}
 %
 % \subsection{Formatting integers}
 %
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index b469bc5..43899b2 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1355,11 +1355,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index ef00fba..c11f36b 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index dc8d995..2d113a3 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index f3e2708..504c1a7 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 0de0071..9f29f3f 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index b469bc5..43899b2 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1355,11 +1355,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index ef00fba..c11f36b 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index dc8d995..2d113a3 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index f3e2708..504c1a7 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 0de0071..9f29f3f 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1353,11 +1353,13 @@ Defining \__int_step:wwwN on line ...
 Defining \__int_step:NnnnN on line ...
 Defining \int_step_function:nN on line ...
 Defining \int_step_function:nnN on line ...
+Defining \int_step_inline:nn on line ...
+Defining \int_step_inline:nnn on line ...
 Defining \int_step_inline:nnnn on line ...
+Defining \int_step_variable:nNn on line ...
+Defining \int_step_variable:nnNn on line ...
 Defining \int_step_variable:nnnNn on line ...
 Defining \__int_step:NNnnnn on line ...
-Defining \int_step_inline:nn on line ...
-Defining \int_step_inline:nnn on line ...
 Defining \int_to_arabic:n on line ...
 Defining \int_to_symbols:nnn on line ...
 Defining \__int_to_symbols:nnnn on line ...
diff --git a/l3kernel/testfiles/m3int003.lvt b/l3kernel/testfiles/m3int003.lvt
index 48b992b..f11c578 100644
--- a/l3kernel/testfiles/m3int003.lvt
+++ b/l3kernel/testfiles/m3int003.lvt
@@ -1,5 +1,5 @@
 %
-% Copyright (C) 2009-2014 The LaTeX3 Project
+% Copyright (C) 2009-2014,2018 The LaTeX3 Project
 %
 \documentclass{minimal}
 \input{regression-test}
@@ -184,6 +184,12 @@
     F:  \int_step_function:nnnN {5} {0} {10} \myfunc
     \NEWLINE
     G:  \int_step_function:nnnN { 1 } { \c_max_int - 1 } { 1 } \myfunc
+    \NEWLINE
+    H:  \int_step_function:nnN { 2 } { 6 } \myfunc
+    \NEWLINE
+    I:  \int_step_function:nN { 3 } \myfunc
+    \NEWLINE
+    J:  \int_step_function:nN { -1 } \myfunc
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -203,6 +209,12 @@
     \int_step_inline:nnnn {-1} {-2} {-10} {\typeout{[#1]}}
     \SEPARATOR
     \int_step_inline:nnnn {5} {0} {10} {\typeout{[#1]}}
+    \SEPARATOR
+    \int_step_inline:nnn { -6 } { -2 } {\typeout{[#1]}}
+    \SEPARATOR
+    \int_step_inline:nn { -3 } {\typeout{[#1]}}
+    \SEPARATOR
+    \int_step_inline:nn { 2 } {\typeout{[#1]}}
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -221,6 +233,12 @@
     \int_step_variable:nnnNn {0} {-1} {-5} \l_tl { \typeout{[\l_tl]~} }
     \SEPARATOR
     \int_step_variable:nnnNn {0} {0} {5} \l_tl { \typeout{[\l_tl]~} }
+    \SEPARATOR
+    \int_step_inline:nnn { -6 } { -2 } {\typeout{[#1]}}
+    \SEPARATOR
+    \int_step_inline:nn { -3 } {\typeout{[#1]}}
+    \SEPARATOR
+    \int_step_inline:nn { 2 } {\typeout{[#1]}}
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3int003.tlg b/l3kernel/testfiles/m3int003.tlg
index ed84aed..27291d9 100644
--- a/l3kernel/testfiles/m3int003.tlg
+++ b/l3kernel/testfiles/m3int003.tlg
@@ -126,6 +126,9 @@ D:[-1]
 E:[-1] [-3] [-5] [-7] [-9] 
 F:
 G:[1] 
+H:[2] [3] [4] [5] [6] 
+I:[1] [2] [3] 
+J:
 ============================================================
 ============================================================
 TEST 9: Stepwise inline
@@ -159,6 +162,16 @@ misspelled it (e.g., `\hobx'), type `I' and the correct
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ============================================================
+[-6]
+[-5]
+[-4]
+[-3]
+[-2]
+============================================================
+============================================================
+[1]
+[2]
+============================================================
 Defining \l_tl on line ...
 ============================================================
 TEST 10: Stepwise variable
@@ -191,6 +204,16 @@ misspelled it (e.g., `\hobx'), type `I' and the correct
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ============================================================
+[-6]
+[-5]
+[-4]
+[-3]
+[-2]
+============================================================
+============================================================
+[1]
+[2]
+============================================================
 ============================================================
 TEST 11: Stepwise with changing bounds
 ============================================================





More information about the latex3-commits mailing list