%% %% 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 "expl3 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 2498 2011-07-09 17:51:47Z joseph $ {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_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 { \clist_if_empty:NTF #3 { \exp_not:o #4 } { \exp_not:o #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_nopar:Npn \clist_put_left:Nn { \clist_put_aux:NNnnNn \tl_set:Nn \tl_put_left:Nn { } , } \cs_new_protected_nopar:Npn \clist_gput_left:Nn { \clist_put_aux:NNnnNn \tl_gset:Nn \tl_gput_left:Nn { } , } \cs_new_protected:Npn \clist_put_aux:NNnnNn #1#2#3#4#5#6 { \clist_if_empty:NTF #5 { #1 #5 {#6} } { \tl_if_empty:nF {#6} { #2 #5 { #3 #6 #4 } } } } \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_aux:NNnnNn \tl_set:Nn \tl_put_right:Nn , { } } \cs_new_protected_nopar:Npn \clist_gput_right:Nn { \clist_put_aux:NNnnNn \tl_gset:Nn \tl_gput_right:Nn , { } } \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:Nn } \cs_new_protected_nopar:Npn \clist_gpop:NN { \clist_pop_aux:NNN \tl_gset:Nn } \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 { \quark_if_nil:nTF {#2} { #4 #5 { } } { #4 #5 {#2} } \tl_set:Nn #6 {#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 \clist_set_eq:NN } \cs_new_protected:Npn \clist_gremove_all:Nn { \clist_remove_all_aux:NNn \clist_gset_eq:NN } \cs_new_protected:Npn \clist_remove_all_aux:NNn #1#2#3 { \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 { \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 } } #1 #2 \l_clist_remove_clist } } \cs_new_protected:Npn \clist_remove_all_aux:w { } \cs_generate_variant:Nn \clist_remove_all:Nn { c } \cs_generate_variant:Nn \clist_gremove_all:Nn { c } \cs_new:Npn \clist_trim_spaces:n #1 { \exp_args:Nf \clist_trim_spaces_aux_i:n { \clist_map_function:nN {#1} \clist_trim_spaces_aux_ii:n } } \cs_new:Npn \clist_trim_spaces_aux_i:n #1 { \use_ii:nn #1 } \cs_new:Npn \clist_trim_spaces_aux_ii:n #1 { , \tl_trim_spaces:n {#1} } \cs_new_protected:Npn \clist_trim_spaces:N #1 { \tl_set:Nf #1 { \exp_args:No \clist_trim_spaces:n #1 } } \cs_new_protected:Npn \clist_gtrim_spaces:N #1 { \tl_gset:Nf #1 { \exp_args:No \clist_trim_spaces:n #1 } } \cs_generate_variant:Nn \clist_trim_spaces:N { c } \cs_generate_variant:Nn \clist_gtrim_spaces:N { c } \cs_new_protected:Npn \clist_tmp:w { } \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 } { \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 } \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 } \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 , \q_recursion_stop } } \cs_new:Npn \clist_map_function:nN #1#2 { \tl_if_empty:nF {#1} { \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \q_recursion_stop } } \cs_new:Npn \clist_map_function_aux:Nw #1#2 , { \quark_if_recursion_tail_stop:n {#2} #1 {#2} \clist_map_function_aux:Nw #1 } \cs_generate_variant:Nn \clist_map_function:NN { c } \int_new:N \g_clist_map_inline_int \cs_new_protected:Npn \clist_map_inline:Nn #1#2 { \int_gincr:N \g_clist_map_inline_int \cs_gset:cpn { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } ##1 {#2} \exp_args:NNc \clist_map_function:NN #1 { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } \int_gdecr:N \g_clist_map_inline_int } \cs_new_protected:Npn \clist_map_inline:nn #1#2 { \int_gincr:N \g_clist_map_inline_int \cs_gset:cpn { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } ##1 {#2} \exp_args:Nnc \clist_map_function:nN {#1} { clist_map_inline_ \int_use:N \g_clist_map_inline_int :n } \int_gdecr:N \g_clist_map_inline_int } \cs_generate_variant:Nn \clist_map_inline:Nn { c } \cs_new_protected:Npn \clist_map_variable:NNn #1#2#3 { \clist_map_inline:Nn #1 { \tl_set:Nn #2 {##1} #3 } } \cs_new_protected:Npn \clist_map_variable:nNn #1#2#3 { \clist_map_inline:nn {#1} { \tl_set:Nn #2 {##1} #3 } } \cs_generate_variant:Nn \clist_map_variable:NNn { c } \cs_new_eq:NN \clist_map_break: \use_none_delimit_by_q_recursion_stop:w \cs_new_eq:NN \clist_map_break:n \use_i_delimit_by_q_recursion_stop:nw \cs_new_protected_nopar:Npn \clist_show:N #1 { \clist_if_empty:NTF #1 { \iow_term:x { Comma~list~\token_to_str:N #1 \c_space_tl is~empty } \tl_show:n { } } { \iow_term:x { Comma~list~\token_to_str:N #1 \c_space_tl contains~the~items~(without~outer~braces): } \tl_set:Nx \l_clist_show_tl { \clist_map_function:NN #1 \clist_show_aux:n } \etex_showtokens:D \exp_after:wN \exp_after:wN \exp_after:wN { \exp_after:wN \clist_show_aux:w \l_clist_show_tl } } } \cs_new:Npn \clist_show_aux:n #1 { \iow_newline: > \c_space_tl \c_space_tl \iow_char:N \{ \exp_not:n {#1} \iow_char:N \} } \cs_new:Npn \clist_show_aux:w #1 > ~ { } \cs_generate_variant:Nn \clist_show:N { c } \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: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_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 { \int_compare:nNnTF {#2} < \c_zero { \exp_args:Nf \clist_item_aux:nw { \int_eval:n { \clist_length:n {#1} + #2 } } #1 , \q_recursion_tail \q_recursion_stop } { \clist_item_aux:nw {#2} #1 , \q_recursion_tail \q_recursion_stop } } \cs_set:Npn \clist_item_aux:nw #1#2 , #3 { \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 } } \cs_generate_variant:Nn \clist_item:Nn { c } \cs_new_protected:Npn \clist_set_from_seq:NN #1#2 { \seq_if_empty:NTF #2 { \clist_clear:N #1 } { \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: } } \cs_new_protected:Npn \clist_gset_from_seq:NN #1#2 { \seq_if_empty:NTF #2 { \clist_gclear:N #1 } { \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_pop_item_def: } } \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 %% %% %% End of file `l3clist.sty'.