summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-12-29 23:03:42 +0000
committerKarl Berry <karl@freefriends.org>2011-12-29 23:03:42 +0000
commit7a50f35d6fd3bd705c78298b1ccc085991638f87 (patch)
tree7f749391d34aa12a37a30a33c00b3098b2320e7c /Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
parent0bc9393ae50667d7ff769a76321a9548a70351fc (diff)
l3kernel 3109 (29dec11)
git-svn-id: svn://tug.org/texlive/trunk@24971 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3seq.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3seq.dtx135
1 files changed, 107 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
index df4beb9ae68..72e6250c070 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3seq.dtx 3033 2011-12-07 10:12:21Z joseph $
+\GetIdInfo$Id: l3seq.dtx 3085 2011-12-22 16:29:26Z bruno $
{L3 Experimental sequences and stacks}
%</driver|package>
%<*driver>
@@ -301,10 +301,11 @@
% Tests if the \meta{sequence} is empty (containing no items).
% \end{function}
%
-% \begin{function}[TF]{
-% \seq_if_in:Nn, \seq_if_in:NV, \seq_if_in:Nv, \seq_if_in:No, \seq_if_in:Nx,
-% \seq_if_in:cn, \seq_if_in:cV, \seq_if_in:cv, \seq_if_in:co, \seq_if_in:cx
-% }
+% \begin{function}[TF]
+% {
+% \seq_if_in:Nn, \seq_if_in:NV, \seq_if_in:Nv, \seq_if_in:No, \seq_if_in:Nx,
+% \seq_if_in:cn, \seq_if_in:cV, \seq_if_in:cv, \seq_if_in:co, \seq_if_in:cx
+% }
% \begin{syntax}
% \cs{seq_if_in:NnTF} \meta{sequence} \Arg{item} \Arg{true code} \Arg{false code}
% \end{syntax}
@@ -632,6 +633,40 @@
% according to the variant chosen.
% \end{function}
%
+% \begin{function}[added = 2011-12-22]
+% {\seq_set_filter:NNn, \seq_gset_filter:NNn}
+% \begin{syntax}
+% \cs{seq_set_filter:NNn} \meta{sequence1} \meta{sequence2} \Arg{inline boolexpr}
+% \end{syntax}
+% Evaluates the \meta{inline boolexpr} for every \meta{item} stored
+% within the \meta{sequence2}. The \meta{inline boolexpr} will
+% receive the \meta{item} as |#1|. The sequence of all \meta{items}
+% for which the \meta{inline boolexpr} evaluated to \texttt{true}
+% is assigned to \meta{sequence1}.
+% \begin{texnote}
+% Contrarily to other mapping functions, \cs{seq_map_break:} cannot
+% be used in this function, and will lead to low-level \TeX{} errors.
+% \end{texnote}
+% \end{function}
+%
+% \begin{function}[added = 2011-12-22]
+% {\seq_set_map:NNn, \seq_gset_map:NNn}
+% \begin{syntax}
+% \cs{seq_set_map:NNn} \meta{sequence1} \meta{sequence2} \Arg{inline function}
+% \end{syntax}
+% Applies \meta{inline function} to every \meta{item} stored
+% within the \meta{sequence2}. The \meta{inline function} should
+% consist of code which will receive the \meta{item} as |#1|.
+% The sequence resulting from \texttt{x}-expanding
+% \meta{inline function} applied to each \meta{item}
+% is assigned to \meta{sequence1}. As such, the code
+% in \meta{inline function} should be expandable.
+% \begin{texnote}
+% Contrarily to other mapping functions, \cs{seq_map_break:} cannot
+% be used in this function, and will lead to low-level \TeX{} errors.
+% \end{texnote}
+% \end{function}
+%
% \section{Internal sequence functions}
%
% \begin{function}{\seq_if_empty_err_break:N}
@@ -801,7 +836,6 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
-%
%
% \begin{macro}{\seq_set_split:Nnn,\seq_gset_split:Nnn}
% \begin{macro}[aux]{\seq_set_split_aux:NNnn}
@@ -833,7 +867,7 @@
{ \seq_set_split_aux:NNnn \tl_set:Nx }
\cs_new_protected_nopar:Npn \seq_gset_split:Nnn
{ \seq_set_split_aux:NNnn \tl_gset:Nx }
-\cs_new_protected_nopar:Npn \seq_set_split_aux:NNnn #1 #2 #3 #4
+\cs_new_protected:Npn \seq_set_split_aux:NNnn #1 #2 #3 #4
{
\tl_if_empty:nTF {#3}
{ #1 #2 { \tl_map_function:nN {#4} \seq_wrap_item:n } }
@@ -872,9 +906,9 @@
% \UnitTested
% Concatenating sequences is easy.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \seq_concat:NNN #1#2#3
+\cs_new_protected:Npn \seq_concat:NNN #1#2#3
{ \tl_set:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } }
-\cs_new_protected_nopar:Npn \seq_gconcat:NNN #1#2#3
+\cs_new_protected:Npn \seq_gconcat:NNN #1#2#3
{ \tl_gset:Nx #1 { \exp_not:o {#2} \exp_not:o {#3} } }
\cs_generate_variant:Nn \seq_concat:NNN { ccc }
\cs_generate_variant:Nn \seq_gconcat:NNN { ccc }
@@ -1047,10 +1081,11 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[TF]{
-% \seq_if_in:Nn, \seq_if_in:NV, \seq_if_in:Nv, \seq_if_in:No, \seq_if_in:Nx,
-% \seq_if_in:cn, \seq_if_in:cV, \seq_if_in:cv, \seq_if_in:co, \seq_if_in:cx
-% }
+% \begin{macro}[TF]
+% {
+% \seq_if_in:Nn, \seq_if_in:NV, \seq_if_in:Nv, \seq_if_in:No, \seq_if_in:Nx,
+% \seq_if_in:cn, \seq_if_in:cV, \seq_if_in:cv, \seq_if_in:co, \seq_if_in:cx
+% }
% \UnitTested
% \begin{macro}[aux]{\seq_if_in_aux:}
% The approach here is to define \cs{seq_item:n} to compare its
@@ -1098,7 +1133,7 @@
% trim off the first item after removing the \cs{seq_item:n} at
% the start.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \seq_get_left:NN #1#2
+\cs_new_protected:Npn \seq_get_left:NN #1#2
{
\seq_if_empty_err_break:N #1
\exp_after:wN \seq_get_left_aux:NnwN #1 \q_stop #2
@@ -1126,7 +1161,7 @@
{ \seq_pop_left_aux:NNN \tl_set:Nn }
\cs_new_protected_nopar:Npn \seq_gpop_left:NN
{ \seq_pop_left_aux:NNN \tl_gset:Nn }
-\cs_new_protected_nopar:Npn \seq_pop_left_aux:NNN #1#2#3
+\cs_new_protected:Npn \seq_pop_left_aux:NNN #1#2#3
{
\seq_if_empty_err_break:N #2
\exp_after:wN \seq_pop_left_aux:NnwNNN #2 \q_stop #1#2#3
@@ -1158,13 +1193,13 @@
% before a tidying-up step takes place to remove the loop and reset the
% meaning of \cs{seq_item:n}.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \seq_get_right:NN #1#2
+\cs_new_protected:Npn \seq_get_right:NN #1#2
{
\seq_if_empty_err_break:N #1
\seq_get_right_aux:NN #1#2
\prg_break_point:n { }
}
-\cs_new_protected_nopar:Npn \seq_get_right_aux:NN #1#2
+\cs_new_protected:Npn \seq_get_right_aux:NN #1#2
{
\seq_push_item_def:n { }
\exp_after:wN \exp_after:wN \exp_after:wN \seq_get_right_loop:nn
@@ -1210,13 +1245,13 @@
{ \seq_pop_right_aux:NNN \tl_set:Nx }
\cs_new_protected_nopar:Npn \seq_gpop_right:NN
{ \seq_pop_right_aux:NNN \tl_gset:Nx }
-\cs_new_protected_nopar:Npn \seq_pop_right_aux:NNN #1#2#3
+\cs_new_protected:Npn \seq_pop_right_aux:NNN #1#2#3
{
\seq_if_empty_err_break:N #2
\seq_pop_right_aux_ii:NNN #1 #2 #3
\prg_break_point:n { }
}
-\cs_new_protected_nopar:Npn \seq_pop_right_aux_ii:NNN #1#2#3
+\cs_new_protected:Npn \seq_pop_right_aux_ii:NNN #1#2#3
{
\seq_push_item_def:n { \seq_wrap_item:n {##1} }
#1 #2 { \if_false: } \fi:
@@ -1267,7 +1302,7 @@
% A function to check that sequences really have some content. This
% is optimised for speed, hence the direct primitive use.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \seq_if_empty_err_break:N #1
+\cs_new_protected:Npn \seq_if_empty_err_break:N #1
{
\if_meaning:w #1 \c_empty_tl
\msg_kernel_error:nnx { seq } { empty-sequence } { \token_to_str:N #1 }
@@ -1445,7 +1480,7 @@
% \UnitTested
% Apply the general \cs{msg_aux_show:Nnx}.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \seq_show:N #1
+\cs_new_protected:Npn \seq_show:N #1
{
\msg_aux_show:Nnx
#1
@@ -1462,7 +1497,7 @@
% The name says it all: of the sequence is empty, returns logical
% \texttt{false}.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_if_empty_break_return_false:N #1
+\cs_new:Npn \seq_if_empty_break_return_false:N #1
{
\if_meaning:w #1 \c_empty_tl
\prg_return_false:
@@ -1580,7 +1615,7 @@
% then the stop code |{ ? \seq_break: } { }| will be used by the auxiliary,
% terminating the loop and returning nothing at all.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_item:Nn #1#2
+\cs_new:Npn \seq_item:Nn #1#2
{
\exp_last_unbraced:Nfo \seq_item_aux:nnn
{
@@ -1596,7 +1631,7 @@
{ }
\prg_break_point:n { }
}
-\cs_new_nopar:Npn \seq_item_aux:nnn #1#2#3
+\cs_new:Npn \seq_item_aux:nnn #1#2#3
{
\use_none:n #2
\int_compare:nNnTF {#1} = \c_zero
@@ -1611,7 +1646,7 @@
% \begin{macro}{\seq_use:N, \seq_use:c}
% A simple short cut for a mapping.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_use:N #1 { \seq_map_function:NN #1 \use:n }
+\cs_new:Npn \seq_use:N #1 { \seq_map_function:NN #1 \use:n }
\cs_generate_variant:Nn \seq_use:N { c }
% \end{macrocode}
% \end{macro}
@@ -1633,7 +1668,7 @@
% avoids needing to find the length of the two sequences, or worrying about
% which is longer.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_mapthread_function:NNN #1#2#3
+\cs_new:Npn \seq_mapthread_function:NNN #1#2#3
{
\exp_after:wN \seq_mapthread_function_aux:NN
\exp_after:wN #3
@@ -1642,7 +1677,7 @@
{ ? \seq_break: } { }
\prg_break_point:n { }
}
-\cs_new_nopar:Npn \seq_mapthread_function_aux:NN #1#2
+\cs_new:Npn \seq_mapthread_function_aux:NN #1#2
{
\exp_after:wN \seq_mapthread_function_aux:Nnnwnn
\exp_after:wN #1
@@ -1750,7 +1785,7 @@
{ \seq_reverse_aux:NN \tl_set:Nx }
\cs_new_protected_nopar:Npn \seq_greverse:N
{ \seq_reverse_aux:NN \tl_gset:Nx }
-\cs_new_protected_nopar:Npn \seq_reverse_aux:NN #1 #2
+\cs_new_protected:Npn \seq_reverse_aux:NN #1 #2
{
\cs_set_eq:NN \seq_tmp:w \seq_item:n
\cs_set_eq:NN \seq_item:n \seq_reverse_aux_item:nwn
@@ -1769,6 +1804,50 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\seq_set_filter:NNn, \seq_gset_filter:NNn}
+% \begin{macro}[aux]{\seq_set_filter_aux:NNNn}
+% Similar to \cs{seq_map_inline:Nn}, without a
+% \cs{prg_break_point:n} because the user's code
+% is performed within the evaluation of a boolean expression,
+% and skipping out of that would break horribly.
+% The \cs{seq_wrap_item:n} function inserts the relevant
+% \cs{seq_item:n} without expansion in the input stream,
+% hence in the \texttt{x}-expanding assignment.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \seq_set_filter:NNn
+ { \seq_set_filter_aux:NNNn \tl_set:Nx }
+\cs_new_protected_nopar:Npn \seq_gset_filter:NNn
+ { \seq_set_filter_aux:NNNn \tl_gset:Nx }
+\cs_new_protected:Npn \seq_set_filter_aux:NNNn #1#2#3#4
+ {
+ \seq_push_item_def:n { \bool_if:nT {#4} { \seq_wrap_item:n {##1} } }
+ #1 #2 { #3 \prg_break_point:n { } }
+ \seq_pop_item_def:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\seq_set_map:NNn,\seq_gset_map:NNn}
+% \begin{macro}[aux]{\seq_set_map_aux:NNNn}
+% Very similar to \cs{seq_set_filter:NNn}. We could actually
+% merge the two within a single function, but it would have weird
+% semantics.
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \seq_set_map:NNn
+ { \seq_set_map_aux:NNNn \tl_set:Nx }
+\cs_new_protected_nopar:Npn \seq_gset_map:NNn
+ { \seq_set_map_aux:NNNn \tl_gset:Nx }
+\cs_new_protected:Npn \seq_set_map_aux:NNNn #1#2#3#4
+ {
+ \seq_push_item_def:n { \exp_not:N \seq_item:n {#4} }
+ #1 #2 { #3 }
+ \seq_pop_item_def:
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Deprecated interfaces}
%
% A few functions which are no longer documented: these were moved