[latex3-commits] [git/LaTeX3-latex3-latex3] peek-regex: Get/set range of intarray entries (90f28581a)

Bruno Le Floch blflatex at gmail.com
Mon Jul 20 02:19:19 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : peek-regex
Link       : https://github.com/latex3/latex3/commit/90f28581afd53c3e5b7d00ee165ba64bf1882193

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

commit 90f28581afd53c3e5b7d00ee165ba64bf1882193
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sun Jul 12 23:41:35 2020 +0200

    Get/set range of intarray entries


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

90f28581afd53c3e5b7d00ee165ba64bf1882193
 l3kernel/l3intarray.dtx         | 45 +++++++++++++++++++++++++++++++++++++++++
 l3kernel/l3kernel-functions.dtx | 25 +++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index 7a96ed287..bbe12b244 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -461,6 +461,51 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}[rEXP]{\__kernel_intarray_range_to_clist:Nnn, \@@_range_to_clist:ww}
+%   Loop through part of the array.
+%    \begin{macrocode}
+\cs_new:Npn \__kernel_intarray_range_to_clist:Nnn #1#2#3
+  {
+    \exp_last_unbraced:Nf \use_none:n
+      {
+        \exp_after:wN \@@_range_to_clist:ww
+        \int_value:w \int_eval:w #2 \exp_after:wN ;
+        \int_value:w \int_eval:w #3 ;
+        #1 \prg_break_point:
+      }
+  }
+\cs_new:Npn \@@_range_to_clist:ww #1 ; #2 ; #3
+  {
+    \if_int_compare:w #1 > #2 \exp_stop_f:
+      \prg_break:n
+    \fi:
+    , \__kernel_intarray_item:Nn #3 {#1}
+    \exp_after:wN \@@_range_to_clist:ww
+    \int_value:w \int_eval:w #1 + \c_one_int ; #2 ; #3
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\__kernel_intarray_gset_range_from_clist:Nnn, \@@_gset_range:Nw}
+%   Loop through part of the array.
+%    \begin{macrocode}
+\cs_new_protected:Npn \__kernel_intarray_gset_range_from_clist:Nnn #1#2#3
+  {
+    \int_set:Nn \l_@@_loop_int {#2}
+    \@@_gset_range:Nw #1 #3 , , \prg_break_point:
+  }
+\cs_new_protected:Npn \@@_gset_range:Nw #1 #2 ,
+  {
+    \if_catcode:w \scan_stop: \tl_to_str:n {#2} \scan_stop:
+      \prg_break:n
+    \fi:
+    \__kernel_intarray_gset:Nnn #1 \l_@@_loop_int {#2}
+    \int_incr:N \l_@@_loop_int
+    \@@_gset_range:Nw #1
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\intarray_show:N, \intarray_show:c, \intarray_log:N, \intarray_log:c}
 %   Convert the list to a comma list (with spaces after each comma)
 %    \begin{macrocode}
diff --git a/l3kernel/l3kernel-functions.dtx b/l3kernel/l3kernel-functions.dtx
index c73b661cf..83e00d978 100644
--- a/l3kernel/l3kernel-functions.dtx
+++ b/l3kernel/l3kernel-functions.dtx
@@ -189,6 +189,31 @@
 %   the \cs{intarray_count:N}, lest a low-level \TeX{} error occur.
 % \end{function}
 %
+% \begin{function}[rEXP, added = 2020-07-12]{\__kernel_intarray_range_to_clist:Nnn}
+%   \begin{syntax}
+%     \cs{__kernel_intarray_range_to_clist:Nnn} \meta{intarray~var} \Arg{start index} \Arg{end index}
+%   \end{syntax}
+%   Converts to integer denotations separated by commas the entries of
+%   the \meta{intarray} from positions \meta{start index} to \meta{end
+%   index} included.  The \meta{start index} and \meta{end index} must
+%   be suitable for a direct assignment to a \TeX{} count register, must
+%   be between $1$ and the \cs{intarray_count:N}, and be suitably
+%   ordered.  All tokens have category code other.
+% \end{function}
+%
+% \begin{function}[added = 2020-07-12]{\__kernel_intarray_gset_range_from_clist:Nnn}
+%   \begin{syntax}
+%     \cs{__kernel_intarray_gset_range_from_clist:Nnn} \meta{intarray~var} \Arg{start index} \Arg{integer clist}
+%   \end{syntax}
+%   Stores the entries of the \meta{clist} as entries of the
+%   \meta{intarray~var} starting from the \meta{start index}, upwards.
+%   This is done without any bound checking.  The \meta{start index} and
+%   all entries of the \meta{integer comma list} (which do not undergo
+%   space trimming and brace stripping as in normal clist mappings) must
+%   be suitable for a direct assignment to a \TeX{} count register.  An
+%   empty entry may stop the loop.
+% \end{function}
+%
 % \begin{function}{\__kernel_ior_open:Nn, \__kernel_ior_open:No}
 %   \begin{syntax}
 %     \cs{__kernel_ior_open:Nn} \meta{stream} \Arg{file name}





More information about the latex3-commits mailing list.