diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3seq.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3seq.sty | 169 |
1 files changed, 114 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty index 80ee168e421..2df60faf409 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty @@ -46,7 +46,7 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3seq.dtx 4500 2013-05-26 11:18:19Z bruno $ +\GetIdInfo$Id: l3seq.dtx 4581 2013-07-28 08:38:50Z joseph $ {L3 Sequences and stacks} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -58,17 +58,25 @@ } \tl_new:N \l__seq_internal_a_tl \tl_new:N \l__seq_internal_b_tl -\cs_new_eq:NN \c_empty_seq \c_empty_tl -\cs_new_eq:NN \seq_new:N \tl_new:N -\cs_new_eq:NN \seq_new:c \tl_new:c -\cs_new_eq:NN \seq_clear:N \tl_clear:N -\cs_new_eq:NN \seq_clear:c \tl_clear:c -\cs_new_eq:NN \seq_gclear:N \tl_gclear:N -\cs_new_eq:NN \seq_gclear:c \tl_gclear:c -\cs_new_eq:NN \seq_clear_new:N \tl_clear_new:N -\cs_new_eq:NN \seq_clear_new:c \tl_clear_new:c -\cs_new_eq:NN \seq_gclear_new:N \tl_gclear_new:N -\cs_new_eq:NN \seq_gclear_new:c \tl_gclear_new:c +\tl_const:Nn \c_empty_seq { \s__seq \s_obj_end } +\cs_new_protected:Npn \seq_new:N #1 + { + \__chk_if_free_cs:N #1 + \cs_gset_eq:NN #1 \c_empty_seq + } +\cs_generate_variant:Nn \seq_new:N { c } +\cs_new_protected:Npn \seq_clear:N #1 + { \seq_set_eq:NN #1 \c_empty_seq } +\cs_generate_variant:Nn \seq_clear:N { c } +\cs_new_protected:Npn \seq_gclear:N #1 + { \seq_gset_eq:NN #1 \c_empty_seq } +\cs_generate_variant:Nn \seq_gclear:N { c } +\cs_new_protected:Npn \seq_clear_new:N #1 + { \seq_if_exist:NTF #1 { \seq_clear:N #1 } { \seq_new:N #1 } } +\cs_generate_variant:Nn \seq_clear_new:N { c } +\cs_new_protected:Npn \seq_gclear_new:N #1 + { \seq_if_exist:NTF #1 { \seq_gclear:N #1 } { \seq_new:N #1 } } +\cs_generate_variant:Nn \seq_gclear_new:N { c } \cs_new_eq:NN \seq_set_eq:NN \tl_set_eq:NN \cs_new_eq:NN \seq_set_eq:Nc \tl_set_eq:Nc \cs_new_eq:NN \seq_set_eq:cN \tl_set_eq:cN @@ -81,10 +89,13 @@ { \__seq_set_split:NNnn \tl_set:Nx } \cs_new_protected_nopar:Npn \seq_gset_split:Nnn { \__seq_set_split:NNnn \tl_gset:Nx } -\cs_new_protected:Npn \__seq_set_split:NNnn #1 #2 #3 #4 +\cs_new_protected:Npn \__seq_set_split: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_internal_a_tl + { \tl_map_function:nN {#4} \__seq_wrap_item:n } + } { \tl_set:Nn \l__seq_internal_a_tl { @@ -98,8 +109,8 @@ \__seq_set_split_auxi:w \prg_do_nothing: } \tl_set:Nx \l__seq_internal_a_tl { \l__seq_internal_a_tl } - #1 #2 { \l__seq_internal_a_tl } } + #1 #2 { \s__seq \l__seq_internal_a_tl \s_obj_end } } \cs_new:Npn \__seq_set_split_auxi:w #1 \__seq_set_split_end: { @@ -111,28 +122,58 @@ { \__seq_wrap_item:n {#1} } \cs_generate_variant:Nn \seq_set_split:Nnn { NnV } \cs_generate_variant:Nn \seq_gset_split:Nnn { NnV } -\cs_new_eq:NN \seq_concat:NNN \tl_concat:NNN -\cs_new_eq:NN \seq_gconcat:NNN \tl_gconcat:NNN -\cs_new_eq:NN \seq_concat:ccc \tl_concat:ccc -\cs_new_eq:NN \seq_gconcat:ccc \tl_gconcat:ccc +\cs_new_protected:Npn \seq_concat:NNN #1#2#3 + { \tl_set:Nf #1 { \exp_last_unbraced:NNo \__seq_concat:NN #2 #3 } } +\cs_new_protected:Npn \seq_gconcat:NNN #1#2#3 + { \tl_gset:Nf #1 { \exp_last_unbraced:NNo \__seq_concat:NN #2 #3 } } +\cs_new:Npn \__seq_concat:NN #1#2 { \exp_after:wN \__seq_concat:w #1 } +\cs_new:Npn \__seq_concat:w #1 \s_obj_end {#1} +\cs_generate_variant:Nn \seq_concat:NNN { ccc } +\cs_generate_variant:Nn \seq_gconcat:NNN { ccc } \prg_new_eq_conditional:NNn \seq_if_exist:N \cs_if_exist:N { TF , T , F , p } \prg_new_eq_conditional:NNn \seq_if_exist:c \cs_if_exist:c { TF , T , F , p } \cs_new_protected:Npn \seq_put_left:Nn #1#2 - { \tl_put_left:Nn #1 { \__seq_item:n {#2} } } -\cs_new_protected:Npn \seq_put_right:Nn #1#2 - { \tl_put_right:Nn #1 { \__seq_item:n {#2} } } + { + \tl_set:Nx #1 + { + \exp_not:n { \s__seq \__seq_item:n {#2} } + \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 } + } + } +\cs_new_protected:Npn \seq_gput_left:Nn #1#2 + { + \tl_gset:Nx #1 + { + \exp_not:n { \s__seq \__seq_item:n {#2} } + \exp_not:f { \exp_after:wN \__seq_put_left_aux:w #1 } + } + } +\cs_new:Npn \__seq_put_left_aux:w \s__seq { \exp_stop_f: } \cs_generate_variant:Nn \seq_put_left:Nn { NV , Nv , No , Nx } \cs_generate_variant:Nn \seq_put_left:Nn { c , cV , cv , co , cx } -\cs_generate_variant:Nn \seq_put_right:Nn { NV , Nv , No , Nx } -\cs_generate_variant:Nn \seq_put_right:Nn { c , cV , cv , co , cx } -\cs_new_protected:Npn \seq_gput_left:Nn #1#2 - { \tl_gput_left:Nn #1 { \__seq_item:n {#2} } } -\cs_new_protected:Npn \seq_gput_right:Nn #1#2 - { \tl_gput_right:Nn #1 { \__seq_item:n {#2} } } \cs_generate_variant:Nn \seq_gput_left:Nn { NV , Nv , No , Nx } \cs_generate_variant:Nn \seq_gput_left:Nn { c , cV , cv , co , cx } +\cs_new_protected:Npn \seq_put_right:Nn #1#2 + { + \tl_set:Nx #1 + { + \exp_after:wN \__seq_put_right_aux:w #1 + \exp_not:n { \__seq_item:n {#2} \s_obj_end } + } + } +\cs_new_protected:Npn \seq_gput_right:Nn #1#2 + { + \tl_gset:Nx #1 + { + \exp_after:wN \__seq_put_right_aux:w #1 + \exp_not:n { \__seq_item:n {#2} \s_obj_end } + } + } +\cs_new:Npn \__seq_put_right_aux:w #1 \s_obj_end { \exp_not:n {#1} } \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_generate_variant:Nn \seq_put_right:Nn { NV , Nv , No , Nx } +\cs_generate_variant:Nn \seq_put_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 @@ -177,10 +218,18 @@ } \cs_generate_variant:Nn \seq_remove_all:Nn { c } \cs_generate_variant:Nn \seq_gremove_all:Nn { c } -\prg_new_eq_conditional:NNn \seq_if_empty:N \tl_if_empty:N - { p , T , F , TF } -\prg_new_eq_conditional:NNn \seq_if_empty:c \tl_if_empty:c - { p , T , F , TF } +\prg_new_conditional:Npnn \seq_if_empty:N #1 { p , T , F , TF } + { + \if_meaning:w #1 \c_empty_seq + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\cs_generate_variant:Nn \seq_if_empty_p:N { c } +\cs_generate_variant:Nn \seq_if_empty:NT { c } +\cs_generate_variant:Nn \seq_if_empty:NF { c } +\cs_generate_variant:Nn \seq_if_empty:NTF { c } \prg_new_protected_conditional:Npnn \seq_if_in:Nn #1#2 { T , F , TF } { @@ -228,30 +277,33 @@ { \tl_set:Nx #2 { - \exp_after:wN \__seq_get_left:Nnw + \exp_after:wN \__seq_get_left:wnw #1 \__seq_item:n { \q_no_value } \q_stop } } -\cs_new:Npn \__seq_get_left:Nnw \__seq_item:n #1#2 \q_stop - { \exp_not:n {#1} } +\cs_new:Npn \__seq_get_left:wnw #1 \__seq_item:n #2#3 \q_stop + { \exp_not:n {#2} } \cs_generate_variant:Nn \seq_get_left:NN { c } \cs_new_protected_nopar:Npn \seq_pop_left:NN { \__seq_pop:NNNN \__seq_pop_left:NNN \tl_set:Nn } \cs_new_protected_nopar:Npn \seq_gpop_left:NN { \__seq_pop:NNNN \__seq_pop_left:NNN \tl_gset:Nn } \cs_new_protected:Npn \__seq_pop_left:NNN #1#2#3 - { \exp_after:wN \__seq_pop_left:NnwNNN #2 \q_stop #1#2#3 } -\cs_new_protected:Npn \__seq_pop_left:NnwNNN \__seq_item:n #1#2 \q_stop #3#4#5 + { \exp_after:wN \__seq_pop_left:wnwNNN #2 \q_stop #1#2#3 } +\cs_new_protected:Npn \__seq_pop_left:wnwNNN + #1 \__seq_item:n #2#3 \q_stop #4#5#6 { - #3 #4 {#2} - \tl_set:Nn #5 {#1} + #4 #5 { #1 #3 } + \tl_set:Nn #6 {#2} } \cs_generate_variant:Nn \seq_pop_left:NN { c } \cs_generate_variant:Nn \seq_gpop_left:NN { c } \cs_new_protected:Npn \seq_get_right:NN #1#2 + { \exp_after:wN \__seq_get_right_setup:wN #1 #2 } +\cs_new_protected:Npn \__seq_get_right_setup:wN \s__seq #1 \s_obj_end #2 { - \exp_after:wN \__seq_get_right_loop:nn - \exp_after:wN \q_no_value + \__seq_get_right_loop:nn + \q_no_value #1 { ?? @@ -274,18 +326,18 @@ \cs_set_eq:NN \seq_tmp:w \__seq_item:n \cs_set_eq:NN \__seq_item:n \scan_stop: #1 #2 - { \if_false: } \fi: - \exp_after:wN \exp_after:wN - \exp_after:wN \__seq_pop_right_loop:nn - \exp_after:wN \use_none:n + { \if_false: } \fi: \s__seq + \exp_after:wN \__seq_pop_right_setup:w #2 { - \if_false: { \fi: } + \s_obj_end \if_false: { \fi: } \tex_afterassignment:D \use_none:n \tl_set:Nx #3 } \cs_set_eq:NN \__seq_item:n \seq_tmp:w } +\cs_new:Npn \__seq_pop_right_setup:w \s__seq #1 \s_obj_end + { \exp_after:wN \__seq_pop_right_loop:nn \use_none:n #1 } \cs_new:Npn \__seq_pop_right_loop:nn #1#2 { #2 { \exp_not:n {#1} } @@ -328,9 +380,10 @@ \cs_new_nopar:Npn \seq_map_break:n { \__prg_map_break:Nn \seq_map_break: } \cs_new:Npn \seq_map_function:NN #1#2 + { \exp_after:wN \__seq_map_function:wN #1 #2 } +\cs_new:Npn \__seq_map_function:wN \s__seq #1 \s_obj_end #2 { - \exp_after:wN \__seq_map_function:NNn \exp_after:wN #2 #1 - { ? \seq_map_break: } { } + \__seq_map_function:NNn #2 #1 { ? \seq_map_break: } { } \__prg_break_point:Nn \seq_map_break: { } } \cs_new:Npn \__seq_map_function:NNn #1#2#3 @@ -395,15 +448,18 @@ { \seq_if_exist:NTF #1 { - \int_case:nnn { \seq_count:N #1 } + \int_case:nnF { \seq_count:N #1 } { { 0 } { } - { 1 } { \exp_after:wN \__seq_use:NnNnn #1 \__seq_item:n { } { } } - { 2 } { \exp_after:wN \__seq_use:NnNnn #1 {#2} } + { 1 } + { + \exp_after:wN \__seq_use:wnwnn #1 + \__seq_item:n { } \s_obj_end { } + } + { 2 } { \exp_after:wN \__seq_use:wnwnn #1 {#2} } } { - \exp_after:wN \__seq_use:nwwwwnwn - \exp_after:wN { \exp_after:wN } #1 \__seq_item:n + \exp_after:wN \__seq_use_setup:w #1 \__seq_item:n \q_mark { \__seq_use:nwwwwnwn {#3} } \q_mark { \__seq_use:nwwn {#4} } \q_stop { } @@ -412,8 +468,11 @@ { \__msg_kernel_expandable_error:nnn { kernel } { bad-variable } {#1} } } \cs_generate_variant:Nn \seq_use:Nnnn { c } -\cs_new:Npn \__seq_use:NnNnn \__seq_item:n #1 \__seq_item:n #2#3 - { \exp_not:n { #1 #3 #2 } } +\cs_new:Npn \__seq_use:wnwnn + #1 \__seq_item:n #2#3 \__seq_item:n #4#5 \s_obj_end #6 + { \exp_not:n { #2 #6 #4 } } +\cs_new:Npn \__seq_use_setup:w \s__seq #1 \s_obj_end + { \__seq_use:nwwwwnwn { } #1 } \cs_new:Npn \__seq_use:nwwwwnwn #1 \__seq_item:n #2 \__seq_item:n #3 \__seq_item:n #4#5 \q_mark #6#7 \q_stop #8 |