%% %% This is file `l3clist.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% l3clist.dtx (with options: `package') %% %% EXPERIMENTAL CODE %% %% Do not distribute this file without also distributing the %% source files specified above. %% %% Do not distribute a modified version of this file. %% %% File: l3clist.dtx Copyright (C) 2004-2011 Frank Mittelbach, %% The 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 %% license or (at your option) any later version. The latest version %% of this license is in the file %% %% http://www.latex-project.org/lppl.txt %% %% 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. %% %% ----------------------------------------------------------------------- %% %% The development version of the bundle can be found at %% %% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% %%%%%%%%%%% %% NOTE: %% %%%%%%%%%%% %% %% Snapshots taken from the repository represent work in progress and may %% not work or may contain conflicting material! We therefore ask %% people _not_ to put them into distributions, archives, etc. without %% prior consultation with the LaTeX3 Project. %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} \GetIdInfo$Id: l3clist.dtx 3029 2011-12-06 22:47:30Z joseph $ {L3 Experimental comma separated lists} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \package_check_loaded_expl: \tl_new:N \l_clist_tmpa_clist \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 \cs_new_eq:NN \clist_clear:c \tl_clear:c \cs_new_eq:NN \clist_gclear:N \tl_gclear:N \cs_new_eq:NN \clist_gclear:c \tl_gclear:c \cs_new_eq:NN \clist_clear_new:N \tl_clear_new:N \cs_new_eq:NN \clist_clear_new:c \tl_clear_new:c \cs_new_eq:NN \clist_gclear_new:N \tl_gclear_new:N \cs_new_eq:NN \clist_gclear_new:c \tl_gclear_new:c \cs_new_eq:NN \clist_set_eq:NN \tl_set_eq:NN \cs_new_eq:NN \clist_set_eq:Nc \tl_set_eq:Nc \cs_new_eq:NN \clist_set_eq:cN \tl_set_eq:cN \cs_new_eq:NN \clist_set_eq:cc \tl_set_eq:cc \cs_new_eq:NN \clist_gset_eq:NN \tl_gset_eq:NN \cs_new_eq:NN \clist_gset_eq:Nc \tl_gset_eq:Nc \cs_new_eq:NN \clist_gset_eq:cN \tl_gset_eq:cN \cs_new_eq:NN \clist_gset_eq:cc \tl_gset_eq:cc \cs_new_protected_nopar:Npn \clist_concat:NNN { \clist_concat_aux:NNNN \tl_set:Nx } \cs_new_protected_nopar:Npn \clist_gconcat:NNN { \clist_concat_aux:NNNN \tl_gset:Nx } \cs_new_protected_nopar:Npn \clist_concat_aux:NNNN #1#2#3#4 { #1 #2 { \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_set:Npn \clist_tmp:w #1 { \cs_new:Npn \clist_trim_spaces_generic:nw ##1 ##2 , { \tl_trim_spaces_aux_i:w ##2 \q_nil \q_mark #1 { } \q_mark \tl_trim_spaces_aux_ii:w \tl_trim_spaces_aux_iii:w #1 \q_nil \clist_trim_spaces_generic_aux:w \q_stop {##1} } } \clist_tmp:w {~} \cs_new:Npn \clist_trim_spaces_generic_aux:w #1 \q_nil #2 \q_stop { \exp_args:No \clist_trim_spaces_generic_aux_ii:nn { \use_none:n #1 } } \cs_new:Npn \clist_trim_spaces_generic_aux_ii:nn #1 #2 { #2 {#1} } \cs_new:Npn \clist_trim_spaces:n #1 { \clist_trim_spaces_generic:nw { \clist_trim_spaces_aux:nn { } } \q_mark #1 , \q_recursion_tail, \q_recursion_stop } \cs_new:Npn \clist_trim_spaces_aux:nn #1 #2 { \quark_if_recursion_tail_stop:n {#2} \tl_if_empty:nTF {#2} { \clist_trim_spaces_generic:nw { \clist_trim_spaces_aux:nn {#1} } \q_mark } { #1 \exp_not:n {#2} \clist_trim_spaces_generic:nw { \clist_trim_spaces_aux:nn { , } } \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_left_aux:NNNn \clist_concat:NNN \clist_set:Nn } \cs_new_protected_nopar:Npn \clist_gput_left:Nn { \clist_put_left_aux:NNNn \clist_gconcat:NNN \clist_set:Nn } \cs_new_protected:Npn \clist_put_left_aux:NNNn #1#2#3#4 { #2 \l_clist_tmpa_clist {#4} #1 #3 \l_clist_tmpa_clist #3 } \cs_generate_variant:Nn \clist_put_left:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_put_left:Nn { c , cV , co , cx } \cs_generate_variant:Nn \clist_gput_left:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_gput_left:Nn { c , cV , co , cx } \cs_new_protected:Npn \clist_put_right:Nn { \clist_put_right_aux:NNNn \clist_concat:NNN \clist_set:Nn } \cs_new_protected_nopar:Npn \clist_gput_right:Nn { \clist_put_right_aux:NNNn \clist_gconcat:NNN \clist_gset:Nn } \cs_new_protected:Npn \clist_put_right_aux:NNNn #1#2#3#4 { #2 \l_clist_tmpa_clist {#4} #1 #3 #3 \l_clist_tmpa_clist } \cs_generate_variant:Nn \clist_put_right:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_put_right:Nn { c , cV , co , cx } \cs_generate_variant:Nn \clist_gput_right:Nn { NV , No , Nx } \cs_generate_variant:Nn \clist_gput_right:Nn { c , cV , co , cx } \cs_new_protected_nopar:Npn \clist_get:NN #1#2 { \exp_after:wN \clist_get_aux:wN #1 , \q_stop #2 } \cs_new_protected:Npn \clist_get_aux:wN #1 , #2 \q_stop #3 { \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:Nf } \cs_new_protected_nopar:Npn \clist_gpop: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_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} { #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 \cs_new_eq:NN \clist_push:NV \clist_put_left:NV \cs_new_eq:NN \clist_push:No \clist_put_left:No \cs_new_eq:NN \clist_push:Nx \clist_put_left:Nx \cs_new_eq:NN \clist_push:cn \clist_put_left:cn \cs_new_eq:NN \clist_push:cV \clist_put_left:cV \cs_new_eq:NN \clist_push:co \clist_put_left:co \cs_new_eq:NN \clist_push:cx \clist_put_left:cx \cs_new_eq:NN \clist_gpush:Nn \clist_gput_left:Nn \cs_new_eq:NN \clist_gpush:NV \clist_gput_left:NV \cs_new_eq:NN \clist_gpush:No \clist_gput_left:No \cs_new_eq:NN \clist_gpush:Nx \clist_gput_left:Nx \cs_new_eq:NN \clist_gpush:cn \clist_gput_left:cn \cs_new_eq:NN \clist_gpush:cV \clist_gput_left:cV \cs_new_eq:NN \clist_gpush:co \clist_gput_left:co \cs_new_eq:NN \clist_gpush:cx \clist_gput_left:cx \cs_new_eq:NN \clist_use:N \tl_use:N \cs_new_eq:NN \clist_use:c \tl_use:c \clist_new:N \l_clist_remove_clist \cs_new_protected:Npn \clist_remove_duplicates:N { \clist_remove_duplicates_aux:NN \clist_set_eq:NN } \cs_new_protected:Npn \clist_gremove_duplicates:N { \clist_remove_duplicates_aux:NN \clist_gset_eq:NN } \cs_new_protected:Npn \clist_remove_duplicates_aux:NN #1#2 { \clist_clear:N \l_clist_remove_clist \clist_map_inline:Nn #2 { \clist_if_in:NnF \l_clist_remove_clist {##1} { \clist_put_right:Nn \l_clist_remove_clist {##1} } } #1 #2 \l_clist_remove_clist } \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 \tl_set:Nx } \cs_new_protected:Npn \clist_gremove_all: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 { #1 #2 { \exp_args:No \exp_not:o { \exp_after:wN \use_none:n #2 } } } } \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 } { \exp_args:No \clist_if_in_return:nn #1 {#2} } \prg_new_protected_conditional:Npnn \clist_if_in:nn #1#2 { T , F , TF } { \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 } \cs_generate_variant:Nn \clist_if_in:NnF { NV , No } \cs_generate_variant:Nn \clist_if_in:NnF { c , cV , co } \cs_generate_variant:Nn \clist_if_in:NnTF { NV , No } \cs_generate_variant:Nn \clist_if_in:NnTF { c , cV , co } \cs_generate_variant:Nn \clist_if_in:nnT { nV , no } \cs_generate_variant:Nn \clist_if_in:nnF { nV , no } \cs_generate_variant:Nn \clist_if_in:nnTF { nV , no } \cs_new_nopar:Npn \clist_map_function:NN #1#2 { \clist_if_empty:NF #1 { \exp_last_unbraced:NNo \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \prg_break_point:n { } } } \cs_new:Npn \clist_map_function_aux:Nw #1#2 , { \quark_if_recursion_tail_break:n {#2} #1 {#2} \clist_map_function_aux:Nw #1 } \cs_generate_variant:Nn \clist_map_function:NN { c } \cs_new:Npn \clist_map_function:nN #1#2 { \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #2 } \q_mark #1, \q_recursion_tail, \prg_break_point:n { } } \cs_new:Npn \clist_map_function_n_aux:Nn #1 #2 { \quark_if_recursion_tail_break:n {#2} \tl_if_empty:nF {#2} { \clist_map_aux_unbrace:Nw #1 #2, } \clist_trim_spaces_generic:nw { \clist_map_function_n_aux:Nn #1 } \q_mark } \cs_new:Npn \clist_map_aux_unbrace:Nw #1 #2, { #1 {#2} } \cs_new_protected:Npn \clist_map_inline:Nn #1#2 { \clist_if_empty:NF #1 { \int_gincr:N \g_prg_map_int \cs_gset:cpn { clist_map_ \int_use:N \g_prg_map_int :n } ##1 {#2} \exp_last_unbraced:Nco \clist_map_function_aux:Nw { clist_map_ \int_use:N \g_prg_map_int :n } #1 , \q_recursion_tail , \prg_break_point:n { \int_gdecr:N \g_prg_map_int } } } \cs_new_protected:Npn \clist_map_inline:nn #1 { \clist_set:Nn \l_clist_tmpa_clist {#1} \clist_map_inline:Nn \l_clist_tmpa_clist } \cs_generate_variant:Nn \clist_map_inline:Nn { c } \cs_new_protected:Npn \clist_map_variable:NNn #1#2#3 { \clist_if_empty:NF #1 { \exp_args:Nno \use:nn { \clist_map_variable_aux:Nnw #2 {#3} } #1 , \q_recursion_tail , \q_recursion_stop \prg_break_point:n { } } } \cs_new_protected:Npn \clist_map_variable:nNn #1 { \clist_set:Nn \l_clist_tmpa_clist {#1} \clist_map_variable:NNn \l_clist_tmpa_clist } \cs_new_protected:Npn \clist_map_variable_aux:Nnw #1#2#3, { \tl_set:Nn #1 {#3} \quark_if_recursion_tail_stop:N #1 \use:n {#2} \clist_map_variable_aux:Nnw #1 {#2} } \cs_generate_variant:Nn \clist_map_variable:NNn { c } \cs_new_eq:NN \clist_map_break: \prg_map_break: \cs_new_eq:NN \clist_map_break:n \prg_map_break:n \cs_new_protected_nopar:Npn \clist_show:N #1 { \msg_aux_show:Nnx #1 { clist } { \clist_map_function:NN #1 \msg_aux_show:n } } \cs_new_protected:Npn \clist_show:n #1 { \clist_set:Nn \l_clist_tmpa_clist {#1} \msg_aux_show:Nnx \l_clist_tmpa_clist { clist } { \clist_map_function:NN \l_clist_tmpa_clist \msg_aux_show:n } } \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 { 0 \clist_map_function:NN #1 \clist_length_aux:n } } \cs_new:Npn \clist_length_aux:n #1 { +1 } \cs_new:Npx \clist_length:n #1 { \exp_not:N \int_eval:n { 0 \exp_not:N \clist_length_n_aux:w \c_space_tl #1 \exp_not:n { , \q_recursion_tail , \q_recursion_stop } } } \cs_new:Npx \clist_length_n_aux:w #1 , { \exp_not:n { \exp_args:Nf \quark_if_recursion_tail_stop:n } {#1} \exp_not:N \tl_if_blank:nF {#1} { + \c_one } \exp_not:N \clist_length_n_aux:w \c_space_tl } \cs_generate_variant:Nn \clist_length:N { c } \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 {#4} < \c_zero { \int_compare:nNnTF {#4} < { - #1 } { \use_none_delimit_by_q_stop:w } { \exp_args:Nf #3 { \int_eval:n { #4 + #1 } } } } { \int_compare:nNnTF {#4} < {#1} { #3 {#4} } { \use_none_delimit_by_q_stop:w } } #2, \q_stop } \cs_new:Npn \clist_item_N_loop:nw #1 #2, { \int_compare:nNnTF {#1} = \c_zero { \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:Npn \clist_item:nn #1#2 { \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: } { \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:Npn \clist_item_n_end:n #1 #2 \q_stop { \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 { , \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_protected:Npn \clist_const:Nn #1#2 { \tl_const:Nx #1 { \clist_trim_spaces:n {#2} } } \cs_generate_variant:Nn \clist_const:Nn { c , Nx , cx } \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 } %% %% %% End of file `l3clist.sty'.