summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3seq.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3seq.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3seq.dtx87
1 files changed, 46 insertions, 41 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3seq.dtx b/Master/texmf-dist/source/latex/expl3/l3seq.dtx
index 4ce306b7d41..6e72397646d 100644
--- a/Master/texmf-dist/source/latex/expl3/l3seq.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3seq.dtx
@@ -1,5 +1,5 @@
% \iffalse
-%% File: l3seq.dtx Copyright (C) 1990-2009 LaTeX3 project
+%% File: l3seq.dtx Copyright (C) 1990-2010 LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -36,7 +36,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: l3seq.dtx 1692 2009-11-03 21:02:34Z joseph $
+\GetIdInfo$Id: l3seq.dtx 1857 2010-03-21 21:32:09Z joseph $
{L3 Experimental sequences and stacks}
%\iffalse
%<*driver>
@@ -284,6 +284,12 @@
% within write operations etc.
% \end{function}
%
+% \begin{function}{ \seq_map_break: | \seq_map_break:n }
+% These functions are used to break out of a mapping function at the point
+% of execution. (Please do not put `|\q_stop|' inside a <seq> that uses
+% these functions.)
+% \end{function}
+%
% \begin{function}{ \seq_show:N |
% \seq_show:c }
% \begin{syntax}
@@ -371,11 +377,6 @@
% meant for direct use.
% \end{function}
%
-% \begin{function}{ \seq_map_break: | \seq_map_break:n }
-% Functions used to implement mapping operations. They are not for
-% meant for direct use.
-% \end{function}
-%
% \begin{function}{ \seq_elt:w |
% \seq_elt_end: }
% Functions (usually used as constants) that separates items within a
@@ -545,7 +546,7 @@
% |\seq_gconcat:NNN| \m{seq~1} \m{seq~2} \m{seq~3} will globally
% assign \m{seq~1} the concatenation of \m{seq~2} and \m{seq~3}.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_gconcat:NNN #1#2#3 {
+\cs_new_protected_nopar:Npn \seq_gconcat:NNN #1#2#3 {
\tl_gset:Nx #1 { \exp_not:V #2 \exp_not:V #3 }
}
\cs_generate_variant:Nn \seq_gconcat:NNN {ccc}
@@ -577,7 +578,7 @@
% next line of code should be probably removed.
% (Will: I have no idea what this comment means.)
% \begin{macrocode}
- \tl_clear:N \l_testa_tl % catch prefixes
+ \tl_clear:N \l_kernel_testa_tl % catch prefixes
\msg_kernel_bug:x {Empty~sequence~`\token_to_str:N#1'}
\fi:
}
@@ -595,7 +596,7 @@
% Note that |##2| in the definition below for "\seq_tmp:w" contains
% exactly one token which we can compare with |\q_no_value|.
% \begin{macrocode}
-\prg_new_conditional:Nnn \seq_if_in:Nn {TF,T,F} {
+\prg_new_protected_conditional:Nnn \seq_if_in:Nn {TF,T,F} {
\cs_set:Npn \seq_tmp:w ##1 \seq_elt:w #2 \seq_elt_end: ##2##3 \q_stop {
\if_meaning:w \q_no_value ##2
\prg_return_false: \else: \prg_return_true: \fi:
@@ -618,11 +619,11 @@
% |\seq_get:NN |\meta{sequence}\meta{cmd} defines \meta{cmd} to be the
% left-most element of \meta{sequence}.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_get:NN #1 {
+\cs_new_protected_nopar:Npn \seq_get:NN #1 {
\seq_if_empty_err:N #1
\exp_after:wN \seq_get_aux:w #1 \q_stop
}
-\cs_new:Npn \seq_get_aux:w \seq_elt:w #1 \seq_elt_end: #2 \q_stop #3 {
+\cs_new_protected:Npn \seq_get_aux:w \seq_elt:w #1 \seq_elt_end: #2 \q_stop #3 {
\tl_set:Nn #3 {#1}
}
\cs_generate_variant:Nn \seq_get:NN {c}
@@ -638,11 +639,11 @@
% \meta{cmd} using \meta{def$\sb2$}, and assigns the tail of
% \meta{sequence} to \meta{sequence} using \meta{def$\sb1$}.
% \begin{macrocode}
-\cs_new:Npn \seq_pop_aux:nnNN #1#2#3 {
+\cs_new_protected:Npn \seq_pop_aux:nnNN #1#2#3 {
\seq_if_empty_err:N #3
\exp_after:wN \seq_pop_aux:w #3 \q_stop #1#2#3
}
-\cs_new:Npn \seq_pop_aux:w
+\cs_new_protected:Npn \seq_pop_aux:w
\seq_elt:w #1 \seq_elt_end: #2\q_stop #3#4#5#6 {
#3 #5 {#2}
#4 #6 {#1}
@@ -663,7 +664,7 @@
% \begin{macro}{\seq_display:N}
% \begin{macro}{\seq_display:c}
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_display:N #1 {
+\cs_new_protected_nopar:Npn \seq_display:N #1 {
\iow_term:x { Sequence~\token_to_str:N #1~contains~
the~elements~(without~outer~braces): }
\toks_clear:N \l_tmpa_toks
@@ -672,7 +673,7 @@
\toks_put_right:Nx \l_tmpa_toks {^^J>~}
}
\toks_put_right:Nx \l_tmpa_toks {
- \iow_space: \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
+ \c_space_tl \iow_char:N \{ \exp_not:n {##1} \iow_char:N \}
}
}
\toks_show:N \l_tmpa_toks
@@ -691,10 +692,10 @@
% elements specified by \meta{left} to the left of \meta{sequence}, and
% those specified by \meta{right} to the right.
% \begin{macrocode}
-\cs_new:Npn \seq_put_aux:Nnn #1 {
+\cs_new_protected:Npn \seq_put_aux:Nnn #1 {
\exp_after:wN \seq_put_aux:w #1 \q_stop #1
}
-\cs_new:Npn \seq_put_aux:w #1\q_stop #2#3#4 { \tl_set:Nn #2 {#3#1#4} }
+\cs_new_protected:Npn \seq_put_aux:w #1\q_stop #2#3#4 { \tl_set:Nn #2 {#3#1#4} }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -715,7 +716,7 @@
% \begin{macro}{\seq_put_right:co}
% Here are the usual operations for adding to the left and right.
% \begin{macrocode}
-\cs_new:Npn \seq_put_left:Nn #1#2 {
+\cs_new_protected:Npn \seq_put_left:Nn #1#2 {
\seq_put_aux:Nnn #1 {\seq_elt:w #2\seq_elt_end:} {}
}
% \end{macrocode}
@@ -726,7 +727,7 @@
\cs_generate_variant:Nn \seq_put_left:Nn {NV,No,Nx,c,cV,co}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn \seq_put_right:Nn #1#2{
+\cs_new_protected:Npn \seq_put_right:Nn #1#2{
\seq_put_aux:Nnn #1{}{\seq_elt:w #2\seq_elt_end:}}
% \end{macrocode}
% \begin{macrocode}
@@ -762,7 +763,7 @@
% \begin{macro}{\seq_gput_right:cV}
% \begin{macro}{\seq_gput_right:co}
% \begin{macrocode}
-\cs_new:Npn \seq_gput_left:Nn {
+\cs_new_protected:Npn \seq_gput_left:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -773,7 +774,7 @@
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new:Npn \seq_gput_right:Nn {
+\cs_new_protected:Npn \seq_gput_right:Nn {
%<*check>
\pref_global_chk:
%</check>
@@ -816,28 +817,32 @@
% \begin{macro}{\seq_map_variable:NNn}
% \begin{macro}{\seq_map_variable:cNn}
% \begin{macro}[aux]{\seq_map_variable_aux:Nnw}
-% \begin{macro}{\seq_map_break:}
-% \begin{macro}{\seq_map_break:n}
% Nothing spectacular here.
% \begin{macrocode}
-\cs_new:Npn \seq_map_variable_aux:Nnw #1#2 \seq_elt:w #3 \seq_elt_end: {
- \tl_set:Nx #1{\exp_not:n{#3}}
+\cs_new_protected:Npn \seq_map_variable_aux:Nnw #1#2 \seq_elt:w #3 \seq_elt_end: {
+ \tl_set:Nn #1 {#3}
\quark_if_nil:NT #1 \seq_map_break:
#2
\seq_map_variable_aux:Nnw #1{#2}
}
-\cs_new:Npn \seq_map_variable:NNn #1#2#3 {
- \tl_set:Nx #2 {\exp_not:n{\seq_map_variable_aux:Nnw #2{#3}}}
+\cs_new_protected:Npn \seq_map_variable:NNn #1#2#3 {
+ \tl_set:Nn #2 {\seq_map_variable_aux:Nnw #2{#3}}
\exp_after:wN #2 #1 \seq_elt:w \q_nil\seq_elt_end: \q_stop
}
\cs_generate_variant:Nn \seq_map_variable:NNn {c}
-
-\cs_new_eq:NN \seq_map_break: \use_none_delimit_by_q_stop:w
-\cs_new_eq:NN \seq_map_break:n \use_i_delimit_by_q_stop:nw
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+%
+% \begin{macro}{\seq_map_break:}
+% \begin{macro}{\seq_map_break:n}
+% Terminate a mapping function at the point of execution. The latter
+% takes an argument to be executed after cleaning up the map.
+% \begin{macrocode}
+\cs_new_eq:NN \seq_map_break: \use_none_delimit_by_q_stop:w
+\cs_new_eq:NN \seq_map_break:n \use_i_delimit_by_q_stop:nw
+% \end{macrocode}
% \end{macro}
% \end{macro}
%
@@ -849,9 +854,9 @@
% better to say that \meta{cmd} must be a function with one argument
% that is delimited by |\seq_elt_end:|.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_map_function:NN #1#2 {
+\cs_new_protected_nopar:Npn \seq_map_function:NN #1#2 {
\cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2{##1}}
- #1
+ #1 \use_none:n \q_stop
\cs_set_eq:NN \seq_elt:w \ERROR
}
\cs_generate_variant:Nn \seq_map_function:NN {c}
@@ -864,9 +869,9 @@
% When no braces are used, this version of mapping seems more
% natural.
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_map_inline:Nn #1#2 {
+\cs_new_protected_nopar:Npn \seq_map_inline:Nn #1#2 {
\cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2}
- #1
+ #1 \use_none:n \q_stop
\cs_set_eq:NN \seq_elt:w \ERROR
}
\cs_generate_variant:Nn \seq_map_inline:Nn {c}
@@ -889,22 +894,22 @@
% \begin{macro}{\seq_gremove_duplicates:N}
% Copied from "\clist_remove_duplicates".
% \begin{macrocode}
-\cs_new:Npn \seq_remove_duplicates_aux:NN #1#2 {
+\cs_new_protected:Npn \seq_remove_duplicates_aux:NN #1#2 {
\seq_clear:N \l_seq_remove_seq
\seq_map_function:NN #2 \seq_remove_duplicates_aux:n
#1 #2 \l_seq_remove_seq
}
-\cs_new:Npn \seq_remove_duplicates_aux:n #1 {
+\cs_new_protected:Npn \seq_remove_duplicates_aux:n #1 {
\seq_if_in:NnF \l_seq_remove_seq {#1} {
\seq_put_right:Nn \l_seq_remove_seq {#1}
}
}
% \end{macrocode}
% \begin{macrocode}
-\cs_new_nopar:Npn \seq_remove_duplicates:N {
+\cs_new_protected_nopar:Npn \seq_remove_duplicates:N {
\seq_remove_duplicates_aux:NN \seq_set_eq:NN
}
-\cs_new_nopar:Npn \seq_gremove_duplicates:N {
+\cs_new_protected_nopar:Npn \seq_gremove_duplicates:N {
\seq_remove_duplicates_aux:NN \seq_gset_eq:NN
}
% \end{macrocode}
@@ -929,7 +934,7 @@
\cs_new_eq:NN \seq_push:NV \seq_put_left:NV
\cs_new_eq:NN \seq_push:No \seq_put_left:No
\cs_new_eq:NN \seq_push:cn \seq_put_left:cn
-\cs_new_nopar:Npn \seq_pop:NN { \seq_pop_aux:nnNN \tl_set:Nn \tl_set:Nn }
+\cs_new_protected_nopar:Npn \seq_pop:NN { \seq_pop_aux:nnNN \tl_set:Nn \tl_set:Nn }
\cs_generate_variant:Nn \seq_pop:NN {c}
% \end{macrocode}
% \end{macro}
@@ -952,7 +957,7 @@
% nevertheless returned locally.
% \begin{macrocode}
\cs_new_eq:NN \seq_gpush:Nn \seq_gput_left:Nn
-\cs_new_nopar:Npn \seq_gpop:NN { \seq_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn }
+\cs_new_protected_nopar:Npn \seq_gpop:NN { \seq_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn }
\cs_generate_variant:Nn \seq_gpush:Nn {NV,No,c,Nv}
\cs_generate_variant:Nn \seq_gpop:NN {c}
% \end{macrocode}