[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add \int_step/inline 'shortcuts' (fixes #454) (ba96ab5)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Apr 22 11:34:33 CEST 2018


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

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

commit ba96ab5f81de1bb117790563d5fe9ea452e20568
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Apr 22 10:34:33 2018 +0100

    Add \int_step/inline 'shortcuts' (fixes #454)


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

ba96ab5f81de1bb117790563d5fe9ea452e20568
 l3kernel/l3int.dtx                      |   34 +++++++++++++++++++++++++++++--
 l3kernel/testfiles/m3expl001.luatex.tlg |    4 ++++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    4 ++++
 l3kernel/testfiles/m3expl001.tlg        |    4 ++++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    4 ++++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    4 ++++
 l3kernel/testfiles/m3expl003.luatex.tlg |    4 ++++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    4 ++++
 l3kernel/testfiles/m3expl003.tlg        |    4 ++++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    4 ++++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    4 ++++
 11 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/l3kernel/l3int.dtx b/l3kernel/l3int.dtx
index 90585da..eb1b4ad 100644
--- a/l3kernel/l3int.dtx
+++ b/l3kernel/l3int.dtx
@@ -492,9 +492,11 @@
 %
 % \section{Integer step functions}
 %
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30, rEXP]
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22, rEXP]
 %   {\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}
 %     \cs{int_step_function:nnnN} \Arg{initial value} \Arg{step} \Arg{final value} \meta{function}
 %   \end{syntax}
 %   This function first evaluates the \meta{initial value}, \meta{step}
@@ -519,11 +521,18 @@
 %     [I saw 4] \quad
 %     [I saw 5] \quad
 %   \end{quote}
+%
+%   The functions \cs{int_step_function:nN} and \cs{int_step_function:nnN}
+%   both use a fixed \meta{step} of $1$, and in the case of
+%   \cs{int_step_function:nN} the \meta{initial value} is also fixed as
+%   $1$. These functions are provided as simple short-cuts for code clarity.
 % \end{function}
 %
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30]
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22]
 %   {\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}
 %     \cs{int_step_inline:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code}
 %   \end{syntax}
 %   This function first evaluates the \meta{initial value}, \meta{step}
@@ -533,6 +542,11 @@
 %   \meta{value}), the \meta{code} is inserted into the input stream
 %   with |#1| replaced by the current \meta{value}.  Thus the
 %   \meta{code} should define a function of one argument~(|#1|).
+%
+%   The functions \cs{int_step_inline:nn} and \cs{int_step_inline:nnn}
+%   both use a fixed \meta{step} of $1$, and in the case of
+%   \cs{int_step_inline:nn} the \meta{initial value} is also fixed as
+%   $1$. These functions are provided as simple short-cuts for code clarity.
 % \end{function}
 %
 % \begin{function}[added = 2012-06-04, updated = 2014-05-30]
@@ -1778,6 +1792,8 @@
 %
 % \begin{macro}{\int_step_function:nnnN}
 % \begin{macro}{\@@_step:wwwN, \@@_step:NnnnN}
+% \begin{macro}{\int_step_function:nN}
+% \begin{macro}{\int_step_function:nnN}
 %   Before all else, evaluate the initial value, step, and final value.
 %   Repeating a function by steps first needs a check on the direction
 %   of the steps. After that, do the function for the start value then
@@ -1821,14 +1837,22 @@
           #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 }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\int_step_inline:nnnn}
 % \begin{macro}{\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}.
@@ -1863,10 +1887,16 @@
     \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 5730d37..b469bc5 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1353,9 +1353,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 4553dfb..ef00fba 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 649098b..dc8d995 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 67813b1..f3e2708 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 871cece..0de0071 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 5730d37..b469bc5 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1353,9 +1353,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 4553dfb..ef00fba 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 649098b..dc8d995 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 67813b1..f3e2708 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 871cece..0de0071 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1351,9 +1351,13 @@ Defining \int_do_until:nNnn on line ...
 Defining \int_step_function:nnnN on line ...
 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: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 ...





More information about the latex3-commits mailing list