[latex3-commits] [l3svn] r7080 - Add fp_step_variable (closes #319)

noreply at latex-project.org noreply at latex-project.org
Wed Apr 12 21:01:39 CEST 2017


Author: bruno
Date: 2017-04-12 21:01:39 +0200 (Wed, 12 Apr 2017)
New Revision: 7080

Modified:
   trunk/l3kernel/l3fp-logic.dtx
   trunk/l3kernel/l3fp.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/m3fp-logic004.luatex.tlg
   trunk/l3kernel/testfiles/m3fp-logic004.lvt
   trunk/l3kernel/testfiles/m3fp-logic004.tlg
Log:
Add fp_step_variable (closes #319)

I'll probably never use it, but it seems natural to include
it for completeness.


Modified: trunk/l3kernel/l3fp-logic.dtx
===================================================================
--- trunk/l3kernel/l3fp-logic.dtx	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/l3fp-logic.dtx	2017-04-12 19:01:39 UTC (rev 7080)
@@ -376,21 +376,39 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\fp_step_inline:nnnn}
+% \begin{macro}{\fp_step_inline:nnnn, \fp_step_variable:nnnNn}
+% \begin{macro}[aux]{\@@_step:NNnnnn}
 %   As for \cs{int_step_inline:nnnn}, create a global function and apply it,
 %   following up with a break point.
 %    \begin{macrocode}
-\cs_new_protected:Npn \fp_step_inline:nnnn #1#2#3#4
+\cs_new_protected:Npn \fp_step_inline:nnnn
   {
     \int_gincr:N \g__prg_map_int
-    \cs_gset_protected:cpn { __prg_map_ \int_use:N \g__prg_map_int :w }
-      ##1 {#4}
-    \fp_step_function:nnnc {#1} {#2} {#3}
+    \exp_args:NNc \@@_step:NNnnnn
+      \cs_gset_protected:Npn
       { __prg_map_ \int_use:N \g__prg_map_int :w }
+  }
+\cs_new_protected:Npn \fp_step_variable:nnnNn #1#2#3#4#5
+  {
+    \int_gincr:N \g__prg_map_int
+    \exp_args:NNc \@@_step:NNnnnn
+      \cs_gset_protected:Npx
+      { __prg_map_ \int_use:N \g__prg_map_int :w }
+      {#1} {#2} {#3}
+      {
+        \tl_set:Nn \exp_not:N #4 {##1}
+        \exp_not:n {#5}
+      }
+  }
+\cs_new_protected:Npn \@@_step:NNnnnn #1#2#3#4#5#6
+  {
+    #1 #2 ##1 {#6}
+    \fp_step_function:nnnN {#3} {#4} {#5} #2
     \__prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__prg_map_int }
   }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 %    \begin{macrocode}
 \__msg_kernel_new:nnn { kernel } { fp-bad-step }

Modified: trunk/l3kernel/l3fp.dtx
===================================================================
--- trunk/l3kernel/l3fp.dtx	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/l3fp.dtx	2017-04-12 19:01:39 UTC (rev 7080)
@@ -573,6 +573,20 @@
 %   \meta{code} should define a function of one argument~(|#1|).
 % \end{function}
 %
+% \begin{function}[added = 2017-04-12]{\fp_step_variable:nnnNn}
+%   \begin{syntax}
+%     \cs{fp_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 floating point expressions.
+%   Then for each \meta{value} from the \meta{initial value} to the
+%   \meta{final value} in turn (using \meta{step} between each
+%   \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}.
+% \end{function}
+%
 % \section{Some useful constants, and scratch variables}
 %
 % \begin{variable}[added = 2012-05-08]{\c_zero_fp, \c_minus_zero_fp}

Modified: trunk/l3kernel/testfiles/m3expl001.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl001.luatex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3839,6 +3839,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl001.ptex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3827,6 +3827,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl001.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3827,6 +3827,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl001.uptex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3827,6 +3827,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl001.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl001.xetex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3837,6 +3837,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl003.luatex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3840,6 +3840,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.ptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl003.ptex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3828,6 +3828,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl003.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3828,6 +3828,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.uptex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl003.uptex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3828,6 +3828,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3expl003.xetex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3expl003.xetex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -3838,6 +3838,8 @@
 Defining \__fp_step:NnnnnN on line ...
 Defining \__fp_step:NfnnnN on line ...
 Defining \fp_step_inline:nnnn on line ...
+Defining \fp_step_variable:nnnNn on line ...
+Defining \__fp_step:NNnnnn on line ...
 Defining message LaTeX/kernel/fp-bad-step on line ...
 Defining message LaTeX/kernel/fp-tiny-step on line ...
 Defining \__fp_minmax_o:Nw on line ...

Modified: trunk/l3kernel/testfiles/m3fp-logic004.luatex.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3fp-logic004.luatex.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3fp-logic004.luatex.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -129,3 +129,78 @@
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ============================================================
+============================================================
+TEST 3: fp_step_variable
+============================================================
+0##
+0.1##
+0.2##
+0.3##
+0.4##
+0.5##
+0.6##
+0.7##
+0.8##
+0.9##
+1##
+1
+0.9
+0.8
+0.7
+0.6
+0.5
+0.4
+0.3
+0.2
+0.1
+0
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Zero step size for step function \__prg_map_1:w .
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Invalid step size inf in step function \__prg_map_1:w .
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Invalid operation fp_to_decimal(-inf)
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+-10000000000000000000000000000...
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Tiny step size (-inf+1=-inf) in step function \__prg_map_1:w .
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+9999999999999998
+9999999999999999
+10000000000000000
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                Tiny step size (1e16+1=1e16) in step function \__prg_map_1:w .
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+============================================================

Modified: trunk/l3kernel/testfiles/m3fp-logic004.lvt
===================================================================
--- trunk/l3kernel/testfiles/m3fp-logic004.lvt	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3fp-logic004.lvt	2017-04-12 19:01:39 UTC (rev 7080)
@@ -50,4 +50,16 @@
     \fp_step_inline:nnnn { 1e16-2 } { 1 }  { 1e16+10 } { \TYPE {#1} }
   }
 
+\TEST { fp_step_variable }
+  {
+    \fp_step_variable:nnnNn { 0 } { 0.1 }  { 1 } \l_tmpa_tl { \TYPE { \tl_to_str:N \l_tmpa_tl # } }
+    \fp_step_variable:nnnNn { 0 } { -0.1 } { 1 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { 1 } { -0.1 } { 0 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { 1 } { 0.1 }  { 0 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { 1 } { 0 }    { 0 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { 1 } { inf }  { 0 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { -inf } { 1 } { 0 } \l_tmpa_tl { \exp_args:NV \test_type:n { \l_tmpa_tl } }
+    \fp_step_variable:nnnNn { 1e16-2 } { 1 }  { 1e16+10 } \l_tmpa_tl { \TYPE { \l_tmpa_tl } }
+  }
+
 \END

Modified: trunk/l3kernel/testfiles/m3fp-logic004.tlg
===================================================================
--- trunk/l3kernel/testfiles/m3fp-logic004.tlg	2017-04-12 18:51:35 UTC (rev 7079)
+++ trunk/l3kernel/testfiles/m3fp-logic004.tlg	2017-04-12 19:01:39 UTC (rev 7080)
@@ -129,3 +129,78 @@
 spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ============================================================
+============================================================
+TEST 3: fp_step_variable
+============================================================
+0##
+0.1##
+0.2##
+0.3##
+0.4##
+0.5##
+0.6##
+0.7##
+0.8##
+0.9##
+1##
+1
+0.9
+0.8
+0.7
+0.6
+0.5
+0.4
+0.3
+0.2
+0.1
+0
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Zero step size for step function \__prg_map_1:w .
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Invalid step size inf in step function \__prg_map...
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Invalid operation fp_to_decimal(-inf)
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+-10000000000000000000000000000...
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Tiny step size (-inf+1=-inf) in step function \__...
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+9999999999999998
+9999999999999999
+10000000000000000
+! Undefined control sequence.
+<argument> \LaTeX3 error: 
+                           Tiny step size (1e16+1=1e16) in step function \__...
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+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.
+============================================================



More information about the latex3-commits mailing list