[latex3-commits] [git/LaTeX3-latex3-latex3] master: Implement \seq_set_from_function:NnN, remove \seq_set_int_step:Nnnnn (cab6028)
Bruno Le Floch
bruno at le-floch.fr
Fri Apr 6 18:46:34 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/cab6028e5a34904ee6abb06ed0bdcee32fb79dac
>---------------------------------------------------------------
commit cab6028e5a34904ee6abb06ed0bdcee32fb79dac
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Fri Apr 6 12:46:34 2018 -0400
Implement \seq_set_from_function:NnN, remove \seq_set_int_step:Nnnnn
The new approach is more general. Not sure we should keep \seq_set_map:NNn
but it has been in l3candidates for a while so it would have to be deprecated
properly.
>---------------------------------------------------------------
cab6028e5a34904ee6abb06ed0bdcee32fb79dac
l3kernel/l3candidates.dtx | 94 ++++++++++++++++++++-----------
l3kernel/l3regex.dtx | 11 ++--
l3kernel/l3sort.dtx | 9 +--
l3kernel/testfiles/m3expl001.luatex.tlg | 8 ++-
l3kernel/testfiles/m3expl001.ptex.tlg | 8 ++-
l3kernel/testfiles/m3expl001.tlg | 8 ++-
l3kernel/testfiles/m3expl001.uptex.tlg | 8 ++-
l3kernel/testfiles/m3expl001.xetex.tlg | 8 ++-
l3kernel/testfiles/m3expl003.luatex.tlg | 8 ++-
l3kernel/testfiles/m3expl003.ptex.tlg | 8 ++-
l3kernel/testfiles/m3expl003.tlg | 8 ++-
l3kernel/testfiles/m3expl003.uptex.tlg | 8 ++-
l3kernel/testfiles/m3expl003.xetex.tlg | 8 ++-
13 files changed, 123 insertions(+), 71 deletions(-)
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 03f603d..8f26638 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -610,21 +610,42 @@
% items in the \meta{comma list}.
% \end{function}
%
-% \begin{function}[added = 2018-04-02]
-% {\seq_set_int_step:Nnnnn, \seq_gset_int_step:Nnnnn}
+% \begin{function}[added = 2018-04-06]
+% {\seq_set_from_function:NnN, \seq_gset_from_function:NnN}
% \begin{syntax}
-% \cs{seq_set_int_step:Nnnnn} \meta{seq~var} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{inline code}
+% \cs{seq_set_from_function:NnN} \meta{seq~var} \Arg{loop~code} \meta{function}
% \end{syntax}
-% This function first evaluates the \meta{initial value}, \meta{step}
-% and \meta{final value}, all of which should be integer expressions.
-% For each \meta{value} from the \meta{initial value} to the
-% \meta{final value} in turn (using \meta{step} between each
-% \meta{value}), the result of \texttt{x}-expanding the \meta{inline
-% code} applied to that \meta{value} is stored as an item in the
-% \meta{seq~var}. The \meta{inline function} should consist of code
-% which will receive the \meta{item} as |#1| and expand to the desired
-% item. As such, the code in \meta{inline function} should be
-% expandable.
+% Sets the \meta{seq~var} equal to a sequence whose items are obtained
+% by \texttt{x}-expanding \meta{loop~code} \meta{function}. This
+% expansion must result in successive calls to the \meta{function}
+% with no nonexpandable tokens in between. More precisely the
+% \meta{function} is replaced by a wrapper function that inserts the
+% appropriate separators between items in the sequence. The
+% \meta{loop~code} must be expandable; it can be for example
+% \cs{tl_map_function:NN} \meta{tl~var} or \cs{clist_map_function:nN}
+% \Arg{clist} or \cs{int_step_function:nnnN} \Arg{initial value}
+% \Arg{step} \Arg{final value}.
+% \end{function}
+%
+% \begin{function}[added = 2018-04-06]
+% {\seq_set_from_inline_x:Nnn, \seq_gset_from_inline_x:Nnn}
+% \begin{syntax}
+% \cs{seq_set_from_inline_x:Nnn} \meta{seq~var} \Arg{loop~code} \Arg{inline~code}
+% \end{syntax}
+% Sets the \meta{seq~var} equal to a sequence whose items are obtained
+% by \texttt{x}-expanding \meta{loop~code} applied to a
+% \meta{function} derived from the \meta{inline~code}. A
+% \meta{function} is defined, that takes one argument,
+% \texttt{x}-expands the \meta{inline~code} with that argument
+% as~|#1|, then adds appropriate separators to turn the result into an
+% item of the sequence. The \texttt{x}-expansion of \meta{loop~code}
+% \meta{function} must result in successive calls to the
+% \meta{function} with no nonexpandable tokens in between. The
+% \meta{loop~code} must be expandable; it can be for example
+% \cs{tl_map_function:NN} \meta{tl~var} or \cs{clist_map_function:nN}
+% \Arg{clist} or \cs{int_step_function:nnnN} \Arg{initial value}
+% \Arg{step} \Arg{final value}, but not the analogous \enquote{inline}
+% mappings.
% \end{function}
%
% \section{Additions to \pkg{l3skip}}
@@ -2316,6 +2337,34 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\seq_set_from_inline_x:Nnn, \seq_gset_from_inline_x:Nnn}
+% \begin{macro}{\@@_set_from_inline_x:NNnn}
+% Set \cs{@@_item:n} then map it using the loop code.
+% \begin{macrocode}
+\cs_new_protected:Npn \seq_set_from_inline_x:Nnn
+ { \@@_set_from_inline_x:NNnn \tl_set:Nx }
+\cs_new_protected:Npn \seq_gset_from_inline_x:Nnn
+ { \@@_set_from_inline_x:NNnn \tl_gset:Nx }
+\cs_new_protected:Npn \@@_set_from_inline_x:NNnn #1#2#3#4
+ {
+ \@@_push_item_def:n { \exp_not:N \@@_item:n {#4} }
+ #1 #2 { \s_@@ #3 \@@_item:n }
+ \@@_pop_item_def:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\seq_set_from_function:NnN, \seq_gset_from_function:NnN}
+% Reuse \cs{seq_set_from_inline_x:Nnn}.
+% \begin{macrocode}
+\cs_new_protected:Npn \seq_set_from_function:NnN #1#2#3
+ { \seq_set_from_inline_x:Nnn #1 {#2} { #3 {##1} } }
+\cs_new_protected:Npn \seq_gset_from_function:NnN #1#2#3
+ { \seq_gset_from_inline_x:Nnn #1 {#2} { #3 {##1} } }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\seq_rand_item:N, \seq_rand_item:c}
% Importantly, \cs{seq_item:Nn} only evaluates its argument once.
% \begin{macrocode}
@@ -2340,25 +2389,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\seq_set_int_step:Nnnnn, \seq_gset_int_step:Nnnnn}
-% \begin{macro}{\@@_set_int_step:NNnnnn}
-% Set \cs{@@_item:n} then map it through the range of values using
-% \cs{int_step_function:nnnN}.
-% \begin{macrocode}
-\cs_new_protected:Npn \seq_set_int_step:Nnnnn
- { \@@_set_int_step:NNnnnn \tl_set:Nx }
-\cs_new_protected:Npn \seq_gset_int_step:Nnnnn
- { \@@_set_int_step:NNnnnn \tl_gset:Nx }
-\cs_new_protected:Npn \@@_set_int_step:NNnnnn #1#2#3#4#5#6
- {
- \@@_push_item_def:n { \exp_not:N \@@_item:n {#6} }
- #1 #2 { \s_@@ \int_step_function:nnnN {#3} {#4} {#5} \@@_item:n }
- \@@_pop_item_def:
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
% \subsection{Additions to \pkg{l3skip}}
%
% \begin{macrocode}
diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 1067d86..7d54a52 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -5978,11 +5978,12 @@
{
\flag_clear:n { @@_begin }
\flag_clear:n { @@_end }
- \seq_set_int_step:Nnnnn \l_@@_internal_seq
- { \l_@@_min_submatch_int }
- { 1 }
- { \l_@@_submatch_int - 1 }
- { \@@_extract_seq_aux:n {##1} }
+ \seq_set_from_function:NnN \l_@@_internal_seq
+ {
+ \int_step_function:nnnN { \l_@@_min_submatch_int }
+ { 1 } { \l_@@_submatch_int - 1 }
+ }
+ \@@_extract_seq_aux:n
\int_compare:nNnF
{ \flag_height:n { @@_begin } + \flag_height:n { @@_end } }
= 0
diff --git a/l3kernel/l3sort.dtx b/l3kernel/l3sort.dtx
index ffc4211..647d4ad 100644
--- a/l3kernel/l3sort.dtx
+++ b/l3kernel/l3sort.dtx
@@ -373,10 +373,11 @@
{
\group_begin:
\@@_main:NNNn \seq_map_inline:Nn \seq_map_break:n #2 {#3}
- \seq_gset_int_step:Nnnnn \g_@@_internal_seq
- { \l_@@_min_int }
- { 1 }
- { \l_@@_top_int - 1 }
+ \seq_gset_from_inline_x:Nnn \g_@@_internal_seq
+ {
+ \int_step_function:nnnN
+ { \l_@@_min_int } { 1 } { \l_@@_top_int - 1 }
+ }
{ \tex_the:D \tex_toks:D ##1 }
\group_end:
#1 #2 \g_@@_internal_seq
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index be71e80..7bae6a0 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5695,13 +5695,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index a7f24ee..f3a1074 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5688,13 +5688,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 802497d..47adda5 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5688,13 +5688,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 2083b38..fa690f6 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5686,13 +5686,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 477d392..1477c64 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5668,13 +5668,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index be71e80..7bae6a0 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5695,13 +5695,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index a7f24ee..f3a1074 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5688,13 +5688,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 802497d..47adda5 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5688,13 +5688,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 2083b38..fa690f6 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5686,13 +5686,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 477d392..1477c64 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5668,13 +5668,15 @@ Defining \__seq_set_filter:NNNn on line ...
Defining \seq_set_map:NNn on line ...
Defining \seq_gset_map:NNn on line ...
Defining \__seq_set_map:NNNn on line ...
+Defining \seq_set_from_inline_x:Nnn on line ...
+Defining \seq_gset_from_inline_x:Nnn on line ...
+Defining \__seq_set_from_inline_x:NNnn on line ...
+Defining \seq_set_from_function:NnN on line ...
+Defining \seq_gset_from_function:NnN on line ...
Defining \seq_rand_item:N on line ...
Defining \seq_rand_item:c on line ...
Defining \seq_const_from_clist:Nn on line ...
Defining \seq_const_from_clist:cn on line ...
-Defining \seq_set_int_step:Nnnnn on line ...
-Defining \seq_gset_int_step:Nnnnn on line ...
-Defining \__seq_set_int_step:NNnnnn on line ...
Defining \skip_split_finite_else_action:nnNN on line ...
Defining \sys_if_rand_exist_p: on line ...
Defining \sys_if_rand_exist:T on line ...
More information about the latex3-commits
mailing list