diff options
author | Karl Berry <karl@freefriends.org> | 2011-09-16 22:35:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-09-16 22:35:41 +0000 |
commit | 6d95b4a2c1bbdaea1a3802c822808f476ac5703b (patch) | |
tree | 1abf9117bf53f2de53fbcc62c352acc92780365b /Master/texmf-dist/tex/latex/l3kernel/l3clist.sty | |
parent | b7f762397f5df2d732326713423e31e1bf91b903 (diff) |
l3kernel 2828 (15sep11)
git-svn-id: svn://tug.org/texlive/trunk@23983 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3clist.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3clist.sty | 230 |
1 files changed, 128 insertions, 102 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty index fa86133edb0..5f6330b6b77 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty @@ -23,7 +23,7 @@ %% %% http://www.latex-project.org/lppl.txt %% -%% This file is part of the "expl3 bundle" (The Work in LPPL) +%% This file is part of the "l3kernel bundle" (The Work in LPPL) %% and all files in that bundle must be distributed together. %% %% The released version of this bundle is available from CTAN. @@ -47,13 +47,13 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3clist.dtx 2725 2011-09-05 18:53:03Z bruno $ +\GetIdInfo$Id: l3clist.dtx 2798 2011-09-10 15:42:13Z will $ {L3 Experimental comma separated lists} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \package_check_loaded_expl: \tl_new:N \l_clist_tmpa_tl -\tl_new:N \l_clist_tmpb_tl +\cs_new_protected:Npn \clist_tmp:w { } \cs_new_eq:NN \clist_new:N \tl_new:N \cs_new_eq:NN \clist_new:c \tl_new:c \cs_new_eq:NN \clist_clear:N \tl_clear:N @@ -80,21 +80,13 @@ { #1 #2 { - \clist_if_empty:NTF #3 - { \exp_not:o #4 } - { - \exp_not:o #3 - \clist_if_empty:NF #4 - { - , - \exp_not:o #4 - } - } + \exp_not:o #3 + \clist_if_empty:NF #3 { \clist_if_empty:NF #4 { , } } + \exp_not:o #4 } } \cs_generate_variant:Nn \clist_concat:NNN { ccc } \cs_generate_variant:Nn \clist_gconcat:NNN { ccc } -\cs_new_protected:Npn \clist_tmp:w { } \cs_set:Npn \clist_tmp:w #1 { \cs_new:Npn \clist_trim_spaces_generic:nw ##1 ##2 , @@ -137,6 +129,12 @@ \clist_trim_spaces_aux:n { , } \q_mark } } +\cs_new_protected:Npn \clist_set:Nn #1#2 + { \tl_set:Nx #1 { \clist_trim_spaces:n {#2} } } +\cs_new_protected:Npn \clist_gset:Nn #1#2 + { \tl_gset:Nx #1 { \clist_trim_spaces:n {#2} } } +\cs_generate_variant:Nn \clist_set:Nn { NV , No , Nx , c , cV , co , cx } +\cs_generate_variant:Nn \clist_gset:Nn { NV , No , Nx , c , cV , co , cx } \cs_new_protected_nopar:Npn \clist_put_left:Nn { \clist_put_aux:NNnnNn \tl_set_eq:NN \tl_put_left:Nx { } , } \cs_new_protected_nopar:Npn \clist_gput_left:Nn @@ -169,18 +167,21 @@ { \tl_set:Nn #3 {#1} } \cs_generate_variant:Nn \clist_get:NN { c } \cs_new_protected_nopar:Npn \clist_pop:NN - { \clist_pop_aux:NNN \tl_set:Nn } + { \clist_pop_aux:NNN \tl_set:Nf } \cs_new_protected_nopar:Npn \clist_gpop:NN - { \clist_pop_aux:NNN \tl_gset:Nn } + { \clist_pop_aux:NNN \tl_gset:Nf } \cs_new_protected_nopar:Npn \clist_pop_aux:NNN #1#2#3 - { \exp_after:wN \clist_pop_aux:wNNN #2 , \q_nil , \q_nil , \q_stop #1#2#3 } -\cs_new_protected:Npn \clist_pop_aux:wNNN #1 , #2 , \q_nil , #3 \q_stop #4#5#6 { + \exp_after:wN \clist_pop_aux:wNNN #2 , \q_nil \q_stop #1#2#3 + } +\cs_new_protected:Npn \clist_pop_aux:wNNN #1 , #2 \q_stop #3#4#5 + { + \tl_set:Nn #5 {#1} \quark_if_nil:nTF {#2} - { #4 #5 { } } - { #4 #5 {#2} } - \tl_set:Nn #6 {#1} + { #3 #4 { } } + { #3 #4 { \clist_pop_aux:w \exp_stop_f: #2 } } } +\cs_new_protected:Npn \clist_pop_aux:w #1 , \q_nil {#1} \cs_generate_variant:Nn \clist_pop:NN { c } \cs_generate_variant:Nn \clist_gpop:NN { c } \cs_new_eq:NN \clist_push:Nn \clist_put_left:Nn @@ -219,66 +220,58 @@ \cs_generate_variant:Nn \clist_remove_duplicates:N { c } \cs_generate_variant:Nn \clist_gremove_duplicates:N { c } \cs_new_protected:Npn \clist_remove_all:Nn - { \clist_remove_all_aux:NNn \clist_set_eq:NN } + { \clist_remove_all_aux:NNn \tl_set:Nx } \cs_new_protected:Npn \clist_gremove_all:Nn - { \clist_remove_all_aux:NNn \clist_gset_eq:NN } + { \clist_remove_all_aux:NNn \tl_gset:Nx } \cs_new_protected:Npn \clist_remove_all_aux:NNn #1#2#3 { + \cs_set:Npn \clist_tmp:w ##1 , #3 , + { + ##1 + , \q_mark , \use_none_delimit_by_q_stop:w , + \clist_remove_all_aux: + } + #1 #2 + { + \exp_after:wN \clist_remove_all_aux: + #2 , \q_mark , #3 , \q_stop + } \clist_if_empty:NF #2 { - \clist_clear:N \l_clist_remove_clist - \cs_set_protected:Npn \clist_remove_all_aux:w - ##1 , #3 , ##2 \q_stop - { - \tl_put_right:Nn \l_clist_remove_clist {##1} - \quark_if_no_value:nF {##2} - { \clist_remove_all_aux:w , ##2 \q_stop } - } - \exp_after:wN \clist_remove_all_aux:w - \exp_after:wN , #2 , #3 , \q_no_value \q_stop - \tl_if_empty:NF \l_clist_remove_clist + #1 #2 { - \exp_after:wN \tl_set:No \exp_after:wN - \l_clist_remove_clist \exp_after:wN - { \exp_after:wN \use_none:n \l_clist_remove_clist } + \exp_args:No \exp_not:o + { \exp_after:wN \use_none:n #2 } } - #1 #2 \l_clist_remove_clist } } -\cs_new_protected:Npn \clist_remove_all_aux:w { } +\cs_new:Npn \clist_remove_all_aux: + { \exp_after:wN \clist_remove_all_aux:w \clist_tmp:w , } +\cs_new:Npn \clist_remove_all_aux:w #1 , \q_mark , #2 , { \exp_not:n {#1} } \cs_generate_variant:Nn \clist_remove_all:Nn { c } \cs_generate_variant:Nn \clist_gremove_all:Nn { c } +\clist_new:N \l_clist_if_in_clist \prg_new_eq_conditional:NNn \clist_if_empty:N \tl_if_empty:N { p , T , F , TF } \prg_new_eq_conditional:NNn \clist_if_empty:c \tl_if_empty:c { p , T , F , TF } \prg_new_eq_conditional:NNn \clist_if_eq:NN \tl_if_eq:NN { p , T , F , TF } \prg_new_eq_conditional:NNn \clist_if_eq:Nc \tl_if_eq:Nc { p , T , F , TF } \prg_new_eq_conditional:NNn \clist_if_eq:cN \tl_if_eq:cN { p , T , F , TF } \prg_new_eq_conditional:NNn \clist_if_eq:cc \tl_if_eq:cc { p , T , F , TF } -\prg_new_protected_conditional:Npnn \clist_if_in:Nn #1#2 - { T , F , TF } +\prg_new_protected_conditional:Npnn \clist_if_in:Nn #1#2 { T , F , TF } { - \cs_set_protected:Npn \clist_tmp:w ##1 , #2 , ##2##3 \q_stop - { - \if_meaning:w \q_no_value ##2 - \prg_return_false: - \else: - \prg_return_true: - \fi: - } - \exp_last_unbraced:NNo \clist_tmp:w , #1 , #2 , \q_no_value \q_stop + \exp_args:No \clist_if_in_return:nn #1 {#2} } -\prg_new_protected_conditional:Npnn \clist_if_in:nn #1#2 - { T , F , TF } +\prg_new_protected_conditional:Npnn \clist_if_in:nn #1#2 { T , F , TF } { - \cs_set_protected:Npn \clist_tmp:w ##1 , #2 , ##2##3 \q_stop - { - \if_meaning:w \q_no_value ##2 - \prg_return_false: - \else: - \prg_return_true: - \fi: - } - \clist_tmp:w , #1 , #2 , \q_no_value \q_stop + \clist_set:Nn \l_clist_if_in_clist {#1} + \exp_args:No \clist_if_in_return:nn \l_clist_if_in_clist {#2} + } +\cs_new_protected:Npn \clist_if_in_return:nn #1#2 + { + \cs_set:Npn \clist_tmp:w ##1 ,#2, { } + \tl_if_empty:oTF + { \clist_tmp:w ,#1, {} {} ,#2, } + { \prg_return_false: } { \prg_return_true: } } \cs_generate_variant:Nn \clist_if_in:NnT { NV , No } \cs_generate_variant:Nn \clist_if_in:NnT { c , cV , co } @@ -390,6 +383,10 @@ } \cs_new:Npn \clist_show_aux:w #1 > ~ { } \cs_generate_variant:Nn \clist_show:N { c } +\clist_new:N \l_tmpa_clist +\clist_new:N \l_tmpb_clist +\clist_new:N \g_tmpa_clist +\clist_new:N \g_tmpb_clist \cs_new:Npn \clist_length:N #1 { \int_eval:n @@ -398,76 +395,105 @@ \clist_map_function:NN #1 \clist_length_aux:n } } +\cs_new:Npn \clist_length_aux:n #1 { +1 } \cs_new:Npn \clist_length:n #1 { \int_eval:n { 0 - \clist_map_function:nN {#1} \clist_length_aux:n + \clist_map_function_aux:Nw \clist_length_n_aux:n #1 + , \q_recursion_tail , \q_recursion_stop } } -\cs_new:Npn \clist_length_aux:n #1 { +1 } +\cs_new:Npn \clist_length_n_aux:n #1 { \tl_if_blank:nF {#1} {+1} } \cs_generate_variant:Nn \clist_length:N { c } -\cs_set_nopar:Npn \clist_item:Nn #1#2 - { \exp_args:No \clist_item:nn #1 {#2} } -\cs_set:Npn \clist_item:nn #1#2 +\cs_new:Npn \clist_item:Nn #1#2 + { + \exp_args:Nfo \clist_item_aux:nnNn + { \clist_length:N #1 } + #1 + \clist_item_N_loop:nw + {#2} + } +\cs_new:Npn \clist_item_aux:nnNn #1#2#3#4 { - \int_compare:nNnTF {#2} < \c_zero + \int_compare:nNnTF {#4} < \c_zero { - \exp_args:Nf \clist_item_aux:nw - { \int_eval:n { \clist_length:n {#1} + #2 } } - #1 , \q_recursion_tail \q_recursion_stop + \int_compare:nNnTF {#4} < { - #1 } + { \use_none_delimit_by_q_stop:w } + { \exp_args:Nf #3 { \int_eval:n { #4 + #1 } } } } - { \clist_item_aux:nw {#2} #1 , \q_recursion_tail \q_recursion_stop } + { + \int_compare:nNnTF {#4} < {#1} + { #3 {#4} } + { \use_none_delimit_by_q_stop:w } + } + #2, \q_stop } -\cs_set:Npn \clist_item_aux:nw #1#2 , #3 +\cs_new:Npn \clist_item_N_loop:nw #1 #2, { \int_compare:nNnTF {#1} = \c_zero - { \use_i_delimit_by_q_recursion_stop:nw {#2} } - { - \quark_if_recursion_tail_stop:n {#3} - \exp_args:Nf \clist_item_aux:nw - { \int_eval:n { #1 - 1 } } - #3 - } + { \use_i_delimit_by_q_stop:nw {#2} } + { \exp_args:Nf \clist_item_N_loop:nw { \int_eval:n { #1 - 1 } } } } \cs_generate_variant:Nn \clist_item:Nn { c } -\cs_new_protected:Npn \clist_set_from_seq:NN #1#2 +\cs_new:Npn \clist_item:nn #1#2 { - \seq_if_empty:NTF #2 - { \clist_clear:N #1 } + \exp_args:Nf \clist_item_aux:nnNn + { \clist_length:n {#1} } + {#1} + \clist_item_n_aux:nw + {#2} + } +\cs_new:Npn \clist_item_n_aux:nw #1 + { \clist_item_n_loop:nw {#1} \prg_do_nothing: } +\cs_new:Npn \clist_item_n_loop:nw #1 #2, + { + \exp_args:No \tl_if_blank:nTF {#2} + { \clist_item_n_loop:nw {#1} \prg_do_nothing: } { - \seq_push_item_def:n { , \exp_not:n {{##1}} } - \tl_set:Nx #1 - { \exp_after:wN \use_none:n \tex_romannumeral:D -`\0 #2 } - \seq_pop_item_def: + \int_compare:nNnTF {#1} = \c_zero + { \exp_args:No \clist_item_n_end:n {#2} } + { + \exp_args:Nf \clist_item_n_loop:nw + { \int_eval:n { #1 - 1 } } + \prg_do_nothing: + } } } -\cs_new_protected:Npn \clist_gset_from_seq:NN #1#2 +\cs_new:Npn \clist_item_n_end:n #1 #2 \q_stop { - \seq_if_empty:NTF #2 - { \clist_gclear:N #1 } + \exp_after:wN \exp_after:wN \exp_after:wN \clist_item_n_strip:w + \tl_trim_spaces:n {#1} , + } +\cs_new:Npn \clist_item_n_strip:w #1 , {#1} +\cs_new_protected:Npn \clist_set_from_seq:NN + { \clist_set_from_seq_aux:NNNN \clist_clear:N \tl_set:Nx } +\cs_new_protected:Npn \clist_gset_from_seq:NN + { \clist_set_from_seq_aux:NNNN \clist_gclear:N \tl_gset:Nx } +\cs_new_protected:Npn \clist_set_from_seq_aux:NNNN #1#2#3#4 + { + \seq_if_empty:NTF #4 + { #1 #3 } { - \seq_push_item_def:n { , \exp_not:n {{##1}} } - \tl_gset:Nx #1 - { \exp_after:wN \use_none:n \tex_romannumeral:D -`\0 #2 } + \seq_push_item_def:n + { + , + \tl_if_empty:oTF { \clist_set_from_seq_aux:w ##1 ~ , ##1 ~ } + { \exp_not:n {##1} } + { \exp_not:n { {##1} } } + } + #2 #3 { \exp_last_unbraced:Nf \use_none:n #4 } \seq_pop_item_def: } } +\cs_new:Npn \clist_set_from_seq_aux:w #1 , #2 ~ { } \cs_generate_variant:Nn \clist_set_from_seq:NN { Nc } \cs_generate_variant:Nn \clist_set_from_seq:NN { c , cc } \cs_generate_variant:Nn \clist_gset_from_seq:NN { Nc } \cs_generate_variant:Nn \clist_gset_from_seq:NN { c , cc } -\cs_new_eq:NN \clist_top:NN \clist_get:NN -\cs_new_eq:NN \clist_top:cN \clist_get:cN -\cs_new_eq:NN \clist_remove_element:Nn \clist_remove_all:Nn -\cs_new_eq:NN \clist_gremove_element:Nn \clist_gremove_all:Nn -\cs_new_eq:NN \clist_display:N \clist_show:N -\cs_new_eq:NN \clist_display:c \clist_show:c -\cs_new_protected:Npn \clist_trim_spaces:N #1 - { \tl_set:Nx #1 { \exp_args:No \clist_trim_spaces:n #1 } } -\cs_new_protected:Npn \clist_gtrim_spaces:N #1 - { \tl_gset:Nx #1 { \exp_args:No \clist_trim_spaces:n #1 } } +\cs_new_protected:Npn \clist_trim_spaces:N #1 { \clist_set:No #1 {#1} } +\cs_new_protected:Npn \clist_gtrim_spaces:N #1 { \clist_gset:No #1 {#1} } \cs_generate_variant:Nn \clist_trim_spaces:N { c } \cs_generate_variant:Nn \clist_gtrim_spaces:N { c } %% |