[latex3-commits] [git/LaTeX3-latex3-latex3] luaintarray: Move Random arrays to common block (aee8c6534)

Marcel Fabian Krüger tex at 2krueger.de
Sat Nov 13 09:34:02 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : luaintarray
Link       : https://github.com/latex3/latex3/commit/aee8c653449cf8efda8df69d8819aba2d2fb59fd

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

commit aee8c653449cf8efda8df69d8819aba2d2fb59fd
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sat Nov 13 09:32:00 2021 +0100

    Move Random arrays to common block


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

aee8c653449cf8efda8df69d8819aba2d2fb59fd
 l3kernel/l3intarray.dtx | 103 ++++--------------------------------------------
 1 file changed, 8 insertions(+), 95 deletions(-)

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index e86564154..4a16a7158 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -594,100 +594,6 @@ luacmd('@@_gset_range:wNw', function()
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsubsection{Random arrays}
-%
-% \begin{macro}{\intarray_gset_rand:Nn, \intarray_gset_rand:cn}
-% \begin{macro}{\intarray_gset_rand:Nnn, \intarray_gset_rand:cnn}
-% \begin{macro}
-%   {
-%     \@@_gset_rand:Nnn,
-%     \@@_gset_rand:Nff,
-%     \@@_gset_rand_auxi:Nnnn,
-%     \@@_gset_rand_auxii:Nnnn,
-%     \@@_gset_rand_auxiii:Nnnn,
-%     \@@_gset_all_same:Nn,
-%   }
-%   We only perform the bounds checks once.  This is done by two
-%   \cs{@@_gset_overflow_test:nw}, with an appropriate empty argument to
-%   avoid a spurious \enquote{at position \texttt{\#1}} part in the
-%   error message.  Then calculate the number of choices: this is at
-%   most $(2^{30}-1)-(-(2^{30}-1))+1=2^{31}-1$, which just barely does
-%   not overflow.  For small ranges use \cs{__kernel_randint:n} (making
-%   sure to subtract~$1$ \emph{before} adding the random number to the
-%   \meta{min}, to avoid overflow when \meta{min} or \meta{max} are
-%   $\pm\cs{c_max_int}$), otherwise \cs{__kernel_randint:nn}.  Finally,
-%   if there are no random numbers do not define any of the auxiliaries.
-%    \begin{macrocode}
-\cs_new_protected:Npn \intarray_gset_rand:Nn #1
-  { \intarray_gset_rand:Nnn #1 { 1 } }
-\cs_generate_variant:Nn \intarray_gset_rand:Nn { c }
-\sys_if_rand_exist:TF
-  {
-    \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
-      {
-        \@@_gset_rand:Nff #1
-          { \int_eval:n {#2} } { \int_eval:n {#3} }
-      }
-    \cs_new_protected:Npn \@@_gset_rand:Nnn #1#2#3
-      {
-        \int_compare:nNnTF {#2} > {#3}
-          {
-            \msg_expandable_error:nnnn
-              { kernel } { randint-backward-range } {#2} {#3}
-            \@@_gset_rand:Nnn #1 {#3} {#2}
-          }
-          {
-            \@@_gset_rand_auxi:Nnnn #1 { } {#2} {#3}
-          }
-      }
-    \cs_generate_variant:Nn \@@_gset_rand:Nnn { Nff }
-    \cs_new_protected:Npn \@@_gset_rand_auxi:Nnnn #1#2#3#4
-      {
-        \@@_gset_rand_auxii:Nnnn #1 { } {#4} {#3}
-      }
-    \cs_new_protected:Npn \@@_gset_rand_auxii:Nnnn #1#2#3#4
-      {
-        \exp_args:NNf \@@_gset_rand_auxiii:Nnnn #1
-          { \int_eval:n { #3 - #4 + 1 } } {#4} {#3}
-      }
-    \cs_new_protected:Npn \@@_gset_rand_auxiii:Nnnn #1#2#3#4
-      {
-        \exp_args:NNf \@@_gset_all_same:Nn #1
-          {
-            \int_compare:nNnTF {#2} > \c__kernel_randint_max_int
-              {
-                \exp_stop_f:
-                \int_eval:n { \__kernel_randint:nn {#3} {#4} }
-              }
-              {
-                \exp_stop_f:
-                \int_eval:n { \__kernel_randint:n {#2} - 1 + #3 }
-              }
-          }
-      }
-    \cs_new_protected:Npn \@@_gset_all_same:Nn #1#2
-      {
-        \int_zero:N \l_@@_loop_int
-        \prg_replicate:nn { \intarray_count:N #1 }
-          {
-            \int_incr:N \l_@@_loop_int
-            \__kernel_intarray_gset:Nnn #1 \l_@@_loop_int {#2}
-          }
-      }
-  }
-  {
-    \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
-      {
-        \msg_error:nnn { kernel } { fp-no-random }
-          { \intarray_gset_rand:Nnn #1 {#2} {#3} }
-      }
-  }
-\cs_generate_variant:Nn \intarray_gset_rand:Nnn { c }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % \subsection{Font dimension based implementation}
 %
 % Go to the false branch of the conditional above.
@@ -1049,6 +955,14 @@ luacmd('@@_gset_range:wNw', function()
 %    \end{macrocode}
 % \end{macro}
 %
+%    \begin{macrocode}
+}
+%    \end{macrocode}
+%
+% \subsection{Common parts}
+% Finally some code is shared between both implementations.
+% Currently this is only the support for random arrays.
+%
 % \subsubsection{Random arrays}
 %
 % \begin{macro}{\intarray_gset_rand:Nn, \intarray_gset_rand:cn}
@@ -1146,7 +1060,6 @@ luacmd('@@_gset_range:wNw', function()
 % \end{macro}
 %
 %    \begin{macrocode}
-}
 %</tex>
 %</package>
 %    \end{macrocode}





More information about the latex3-commits mailing list.