summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3seq.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3kernel/l3seq.sty170
1 files changed, 75 insertions, 95 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty
index 0489e8e2378..adfb1684b43 100644
--- a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty
+++ b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty
@@ -46,14 +46,14 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3seq.dtx 2896 2011-10-09 20:36:50Z joseph $
+\GetIdInfo$Id: l3seq.dtx 3033 2011-12-07 10:12:21Z joseph $
{L3 Experimental sequences and stacks}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\package_check_loaded_expl:
\cs_new:Npn \seq_item:n
{
- \msg_expandable_error:n { A~sequence~was~used~incorrectly. }
+ \msg_expandable_kernel_error:nn { seq } { misused }
\use_none:n
}
\tl_new:N \l_seq_tmpa_tl
@@ -76,6 +76,38 @@
\cs_new_eq:NN \seq_gset_eq:Nc \tl_gset_eq:Nc
\cs_new_eq:NN \seq_gset_eq:cN \tl_gset_eq:cN
\cs_new_eq:NN \seq_gset_eq:cc \tl_gset_eq:cc
+\cs_new_protected_nopar:Npn \seq_set_split:Nnn
+ { \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
+ {
+ \tl_if_empty:nTF {#3}
+ { #1 #2 { \tl_map_function:nN {#4} \seq_wrap_item:n } }
+ {
+ \tl_set:Nn \l_seq_tmpa_tl
+ {
+ \seq_set_split_aux_i:w \prg_do_nothing:
+ #4
+ \seq_set_split_aux_end:
+ }
+ \tl_replace_all:Nnn \l_seq_tmpa_tl { #3 }
+ {
+ \seq_set_split_aux_end:
+ \seq_set_split_aux_i:w \prg_do_nothing:
+ }
+ \tl_set:Nx \l_seq_tmpa_tl { \l_seq_tmpa_tl }
+ #1 #2 { \l_seq_tmpa_tl }
+ }
+ }
+\cs_new:Npn \seq_set_split_aux_i:w #1 \seq_set_split_aux_end:
+ {
+ \exp_not:N \seq_set_split_aux_ii:w
+ \exp_args:No \tl_trim_spaces:n {#1}
+ \exp_not:N \seq_set_split_aux_end:
+ }
+\cs_new:Npn \seq_set_split_aux_ii:w #1 \seq_set_split_aux_end:
+ { \seq_wrap_item:n {#1} }
\cs_new_protected_nopar: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
@@ -98,6 +130,7 @@
\cs_generate_variant:Nn \seq_gput_left:Nn { c , cV , cv , co , cx }
\cs_generate_variant:Nn \seq_gput_right:Nn { NV , Nv , No , Nx }
\cs_generate_variant:Nn \seq_gput_right:Nn { c , cV , cv , co , cx }
+\cs_new:Npn \seq_wrap_item:n #1 { \exp_not:n { \seq_item:n {#1} } }
\seq_new:N \l_seq_remove_seq
\cs_new_protected:Npn \seq_remove_duplicates:N
{ \seq_remove_duplicates_aux:NN \seq_set_eq:NN }
@@ -133,7 +166,7 @@
\tl_if_eq:NNT \l_seq_tmpa_tl \l_seq_tmpb_tl
{ \use_none:nn }
}
- \exp_not:n { \seq_item:n {##1} }
+ \seq_wrap_item:n {##1}
}
\tl_set:Nn \l_seq_tmpa_tl {#3}
#1 #2 {#2}
@@ -159,7 +192,7 @@
}
#1
\seq_break:n { \prg_return_false: }
- \seq_break_point:n { \group_end: }
+ \prg_break_point:n { \group_end: }
}
\cs_new_nopar:Npn \seq_if_in_aux: { \seq_break:n { \prg_return_true: } }
\cs_generate_variant:Nn \seq_if_in:NnT { NV , Nv , No , Nx }
@@ -172,7 +205,7 @@
{
\seq_if_empty_err_break:N #1
\exp_after:wN \seq_get_left_aux:NnwN #1 \q_stop #2
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_protected:Npn \seq_get_left_aux:NnwN \seq_item:n #1#2 \q_stop #3
{ \tl_set:Nn #3 {#1} }
@@ -185,7 +218,7 @@
{
\seq_if_empty_err_break:N #2
\exp_after:wN \seq_pop_left_aux:NnwNNN #2 \q_stop #1#2#3
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_protected:Npn \seq_pop_left_aux:NnwNNN \seq_item:n #1#2 \q_stop #3#4#5
{
@@ -198,7 +231,7 @@
{
\seq_if_empty_err_break:N #1
\seq_get_right_aux:NN #1#2
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_protected_nopar:Npn \seq_get_right_aux:NN #1#2
{
@@ -226,11 +259,11 @@
{
\seq_if_empty_err_break:N #2
\seq_pop_right_aux_ii:NNN #1 #2 #3
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_protected_nopar:Npn \seq_pop_right_aux_ii:NNN #1#2#3
{
- \seq_push_item_def:n { \exp_not:n { \seq_item:n {##1} } }
+ \seq_push_item_def:n { \seq_wrap_item:n {##1} }
#1 #2 { \if_false: } \fi:
\exp_after:wN \exp_after:wN \exp_after:wN \seq_get_right_loop:nn
\exp_after:wN \use_none:n #2
@@ -246,11 +279,10 @@
}
\cs_generate_variant:Nn \seq_pop_right:NN { c }
\cs_generate_variant:Nn \seq_gpop_right:NN { c }
-\cs_new:Npn \seq_break: #1 \seq_break_point:n #2 {#2}
-\cs_new:Npn \seq_break:n #1#2 \seq_break_point:n #3 { #3 #1 }
-\cs_new_eq:NN \seq_map_break: \seq_break:
-\cs_new_eq:NN \seq_map_break:n \seq_break:n
-\cs_new_eq:NN \seq_break_point:n \use:n
+\cs_new_eq:NN \seq_break: \prg_map_break:
+\cs_new_eq:NN \seq_break:n \prg_map_break:n
+\cs_new_eq:NN \seq_map_break: \prg_map_break:
+\cs_new_eq:NN \seq_map_break:n \prg_map_break:n
\cs_new_protected_nopar:Npn \seq_if_empty_err_break:N #1
{
\if_meaning:w #1 \c_empty_tl
@@ -262,7 +294,7 @@
{
\exp_after:wN \seq_map_function_aux:NNn \exp_after:wN #2 #1
{ ? \seq_map_break: } { }
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new:Npn \seq_map_function_aux:NNn #1#2#3
{
@@ -283,21 +315,21 @@
}
\cs_new_protected:Npn \seq_push_item_def_aux:
{
- \cs_gset_eq:cN { seq_item_ \int_use:N \g_seq_nesting_depth_int :n }
+ \cs_gset_eq:cN { seq_item_ \int_use:N \g_prg_map_int :n }
\seq_item:n
- \int_gincr:N \g_seq_nesting_depth_int
+ \int_gincr:N \g_prg_map_int
}
\cs_new_protected_nopar:Npn \seq_pop_item_def:
{
- \int_gdecr:N \g_seq_nesting_depth_int
+ \int_gdecr:N \g_prg_map_int
\cs_gset_eq:Nc \seq_item:n
- { seq_item_ \int_use:N \g_seq_nesting_depth_int :n }
+ { seq_item_ \int_use:N \g_prg_map_int :n }
}
\cs_new_protected:Npn \seq_map_inline:Nn #1#2
{
\seq_push_item_def:n {#2}
#1
- \seq_break_point:n { \seq_pop_item_def: }
+ \prg_break_point:n { \seq_pop_item_def: }
}
\cs_generate_variant:Nn \seq_map_inline:Nn { c }
\cs_new_protected:Npn \seq_map_variable:NNn #1#2#3
@@ -308,7 +340,7 @@
\exp_not:n {#3}
}
#1
- \seq_break_point:n { \seq_pop_item_def: }
+ \prg_break_point:n { \seq_pop_item_def: }
}
\cs_generate_variant:Nn \seq_map_variable:NNn { Nc }
\cs_generate_variant:Nn \seq_map_variable:NNn { c , cc }
@@ -338,32 +370,13 @@
\cs_new_eq:NN \seq_pop:cN \seq_pop_left:cN
\cs_new_eq:NN \seq_gpop:NN \seq_gpop_left:NN
\cs_new_eq:NN \seq_gpop:cN \seq_gpop_left:cN
-\tl_new:N \l_seq_show_tl
\cs_new_protected_nopar:Npn \seq_show:N #1
{
- \seq_if_empty:NTF #1
- {
- \iow_term:x { Sequence~\token_to_str:N #1~is~empty }
- \tl_show:n { }
- }
- {
- \iow_term:x
- {
- Sequence~\token_to_str:N #1~
- contains~the~items~(without~outer~braces):
- }
- \tl_set:Nx \l_seq_show_tl
- { \seq_map_function:NN #1 \seq_show_aux:n }
- \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN
- { \exp_after:wN \seq_show_aux:w \l_seq_show_tl }
- }
- }
-\cs_new:Npn \seq_show_aux:n #1
- {
- \iow_newline: > \c_space_tl \c_space_tl
- \iow_char:N \{ \exp_not:n {#1} \iow_char:N \}
+ \msg_aux_show:Nnx
+ #1
+ { seq }
+ { \seq_map_function:NN #1 \msg_aux_show:n }
}
-\cs_new:Npn \seq_show_aux:w #1 > ~ { }
\cs_generate_variant:Nn \seq_show:N { c }
\cs_new_nopar:Npn \seq_if_empty_break_return_false:N #1
{
@@ -378,14 +391,14 @@
\exp_after:wN \seq_get_left_aux:Nw #1 \q_stop #2
\prg_return_true:
\seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\prg_new_protected_conditional:Npnn \seq_get_right:NN #1#2 { T , F , TF }
{
\seq_if_empty_break_return_false:N #1
\seq_get_right_aux:NN #1#2
\prg_return_true: \seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_generate_variant:Nn \seq_get_left:NNT { c }
\cs_generate_variant:Nn \seq_get_left:NNF { c }
@@ -398,28 +411,28 @@
\seq_if_empty_break_return_false:N #1
\exp_after:wN \seq_pop_left_aux:NnwNNN #1 \q_stop \tl_set:Nn #1#2
\prg_return_true: \seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\prg_new_protected_conditional:Npnn \seq_gpop_left:NN #1#2 { T , F , TF }
{
\seq_if_empty_break_return_false:N #1
\exp_after:wN \seq_pop_left_aux:NnwNNN #1 \q_stop \tl_gset:Nn #1#2
\prg_return_true: \seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\prg_new_protected_conditional:Npnn \seq_pop_right:NN #1#2 { T , F , TF }
{
\seq_if_empty_break_return_false:N #1
\seq_pop_right_aux_ii:NNN \tl_set:Nx #1 #2
\prg_return_true: \seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\prg_new_protected_conditional:Npnn \seq_gpop_right:NN #1#2 { T , F , TF }
{
\seq_if_empty_break_return_false:N #1
\seq_pop_right_aux_ii:NNN \tl_gset:Nx #1 #2
\prg_return_true: \seq_break:
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_generate_variant:Nn \seq_pop_left:NNT { c }
\cs_generate_variant:Nn \seq_pop_left:NNF { c }
@@ -457,14 +470,14 @@
#1
{ ? \seq_break: }
{ }
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_nopar:Npn \seq_item_aux:nnn #1#2#3
{
\use_none:n #2
\int_compare:nNnTF {#1} = \c_zero
{ \seq_break:n {#3} }
- { \exp_args:Nf \seq_item_aux:nnn { #1 - 1 } }
+ { \exp_args:Nf \seq_item_aux:nnn { \int_eval:n { #1 - 1 } } }
}
\cs_generate_variant:Nn \seq_item:Nn { c }
\cs_new_nopar:Npn \seq_use:N #1 { \seq_map_function:NN #1 \use:n }
@@ -476,7 +489,7 @@
\exp_after:wN #1
#2
{ ? \seq_break: } { }
- \seq_break_point:n { }
+ \prg_break_point:n { }
}
\cs_new_nopar:Npn \seq_mapthread_function_aux:NN #1#2
{
@@ -515,64 +528,31 @@
\tl_gset:Nx #1
{ \clist_map_function:nN {#2} \seq_wrap_item:n }
}
-\cs_new:Npn \seq_wrap_item:n #1 { \exp_not:n { \seq_item:n {#1} } }
\cs_generate_variant:Nn \seq_set_from_clist:NN { Nc }
\cs_generate_variant:Nn \seq_set_from_clist:NN { c , cc }
\cs_generate_variant:Nn \seq_set_from_clist:Nn { c }
\cs_generate_variant:Nn \seq_gset_from_clist:NN { Nc }
\cs_generate_variant:Nn \seq_gset_from_clist:NN { c , cc }
\cs_generate_variant:Nn \seq_gset_from_clist:Nn { c }
-\cs_new_protected_nopar:Npn \seq_tmp:w
- { \msg_expandable_error:n { There~is~a~bug~in~LaTeX3! } }
-\cs_new_protected_nopar:Npn \seq_set_reverse:N
+\cs_new_protected_nopar:Npn \seq_tmp:w { }
+\cs_new_protected_nopar:Npn \seq_reverse:N
{ \seq_reverse_aux:NN \tl_set:Nx }
-\cs_new_protected_nopar:Npn \seq_gset_reverse:N
+\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_set_eq:NN \seq_tmp:w \seq_item:n
- \cs_set_eq:NN \seq_item:n \seq_reverse_aux_item:w
- #1 #2 { #2 \prg_do_nothing: }
+ \cs_set_eq:NN \seq_item:n \seq_reverse_aux_item:nwn
+ #1 #2 { #2 \exp_not:n { } }
\cs_set_eq:NN \seq_item:n \seq_tmp:w
}
-\cs_new:Npn \seq_reverse_aux_item:w #1 #2 \prg_do_nothing:
+\cs_new:Npn \seq_reverse_aux_item:nwn #1 #2 \exp_not:n #3
{
#2
- \prg_do_nothing:
- \exp_not:n { \seq_item:n {#1} }
- }
-\cs_new_protected_nopar:Npn \seq_set_split:Nnn
- { \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
- {
- \tl_if_empty:nTF {#4}
- { #1 #2 { } }
- {
- \tl_set:Nn \l_seq_tmpa_tl
- {
- \seq_set_split_aux_i:w \prg_do_nothing:
- #4
- \seq_set_split_aux_end:
- }
- \tl_replace_all:Nnn \l_seq_tmpa_tl { #3 }
- {
- \seq_set_split_aux_end:
- \seq_set_split_aux_i:w \prg_do_nothing:
- }
- \tl_set:Nx \l_seq_tmpa_tl { \l_seq_tmpa_tl }
- #1 #2 { \l_seq_tmpa_tl }
- }
- }
-\cs_new:Npn \seq_set_split_aux_i:w #1 \seq_set_split_aux_end:
- {
- \exp_not:N \seq_set_split_aux_ii:w
- \exp_args:No \tl_trim_spaces:n {#1}
- \exp_not:N \seq_set_split_aux_end:
+ \exp_not:n { \seq_item:n {#1} #3 }
}
-\cs_new:Npn \seq_set_split_aux_ii:w #1 \seq_set_split_aux_end:
- { \exp_not:n { \seq_item:n {#1} } }
+\cs_generate_variant:Nn \seq_reverse:N { c }
+\cs_generate_variant:Nn \seq_greverse:N { c }
%%
%%
%% End of file `l3seq.sty'.