%%
%% This is file `l3clist.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3clist.dtx  (with options: `package,trace')
%% 
%% 
%% 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) 2005-2006 Frank Mittelbach, 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/cgi-bin/cvsweb.cgi/
%%
%% 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 LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: l3clist.dtx 745 2008-08-03 18:50:46Z morten $
       {L3 Experimental comma separated lists}
\ProvidesExplPackage
  {\filename}{\filedate}{\fileversion}{\filedescription}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{l3prg,l3quark}
\def_new:Npn \clist_new:N #1{\tlp_new:Nn #1{}}
\def_new:Npn \clist_new:c {\exp_args:Nc \clist_new:N}
\let_new:NN \clist_clear:N \tlp_clear:N
\let_new:NN \clist_clear:c \tlp_clear:c
\let_new:NN \clist_gclear:N \tlp_gclear:N
\let_new:NN \clist_gclear:c \tlp_gclear:c
\let_new:NN \clist_set_eq:NN \let:NN
\let_new:NN \clist_gset_eq:NN \glet:NN
\def_new:Npn \clist_gset_eq:cN {\exp_args:Nc \clist_gset_eq:NN}
\def_new:Npn \clist_gset_eq:Nc {\exp_args:NNc \clist_gset_eq:NN}
\def_new:Npn \clist_gset_eq:cc {\exp_args:Ncc \clist_gset_eq:NN}
\let_new:NN \clist_if_empty_p:N \tlp_if_empty_p:N
\def_test_function_new:npn {clist_if_empty:N}#1{\if_meaning:NN#1\c_empty_tlp}
\def_new:Npn \clist_if_empty:cTF {\exp_args:Nc\clist_if_empty:NTF}
\def_new:Npn \clist_if_empty:cT {\exp_args:Nc\clist_if_empty:NT}
\def_new:Npn \clist_if_empty:cF {\exp_args:Nc\clist_if_empty:NF}
\def_new:Npn \clist_if_empty_err:N #1{
  \if_meaning:NN#1\c_empty_tlp
    \tlp_clear:N \l_testa_tlp % catch prefixes
    \err_latex_bug:x{Empty~comma-list~`\token_to_string:N#1'}
  \fi:}
\let_new:NN \clist_if_eq:NNTF \tlp_if_eq:NNTF
\def_new:Npn \clist_get:NN #1{
  \clist_if_empty_err:N #1
  \exp_after:NN\clist_get_aux:w #1,\q_stop}
\def_new:Npn \clist_get_aux:w  #1,#2\q_stop #3{\tlp_set:Nn #3{#1}}
\def_new:Npn \clist_get:cN {\exp_args:Nc \clist_get:NN}
\def_new:Npn \clist_pop_aux:nnNN #1#2#3{
  \clist_if_empty_err:N #3
  \exp_after:NN\clist_pop_aux:w #3,\q_nil\q_stop #1#2#3}
\def_new:Npn \clist_pop_aux:w  #1,#2\q_stop #3#4#5#6{
   #4#6{#1}
   #3#5{#2}
   \quark_if_nil:NTF #5
   { #3#5{} }
   { \clist_pop_auxi:w #2 #3#5 }
}
\def_new:Npn\clist_pop_auxi:w #1,\q_nil #2#3  {#2#3{#1}}
\def_new:Npn \clist_put_aux:NNnnNn #1#2#3#4#5#6{
  \clist_if_empty:NTF#5 {#1 #5{#6}}
  { \tlist_if_empty:nF {#6}{ #2 #5{#3#6#4} } }
}
\def_new:Npn \clist_put_left:Nn {
  \clist_put_aux:NNnnNn \tlp_set:Nn \tlp_put_left:Nn {} ,
}
\def_new:Npn \clist_put_left:cn {\exp_args:Nc \clist_put_left:Nn}
\def_new:Npn \clist_put_left:No {\exp_args:NNo\clist_put_left:Nn}
\def_new:Npn \clist_put_left:Nx {\exp_args:Nnx\clist_put_left:Nn}
\def_new:Npn \clist_gput_left:Nn {
  \clist_put_aux:NNnnNn \tlp_gset:Nn \tlp_gput_left:Nn {} ,
}
\def_new:Npn \clist_put_right:Nn {
  \clist_put_aux:NNnnNn \tlp_set:Nn \tlp_put_right:Nn , {}
}
\def_new:Npn \clist_put_right:cn {\exp_args:Nc \clist_put_right:Nn}
\def_new:Npn \clist_put_right:No {\exp_args:Nno\clist_put_right:Nn}
\def_new:Npn \clist_put_right:Nx {\exp_args:Nnx\clist_put_right:Nn}
\def_new:Npn \clist_gput_right:Nn {
  \clist_put_aux:NNnnNn \tlp_gset:Nn \tlp_gput_right:Nn , {}
}
\def_new:Npn \clist_gput_right:No {\exp_args:NNo \clist_gput_right:Nn}
\def_new:Npn \clist_gput_right:cn {\exp_args:Nc  \clist_gput_right:Nn}
\def_new:Npn \clist_gput_right:co {\exp_args:Nco \clist_gput_right:Nn}
\def_new:Npn \clist_gput_right:cc {\exp_args:Ncc \clist_gput_right:Nn}
\def_new:Npn \clist_gput_right:NC {\exp_args:NNC \clist_gput_right:Nn}
\def_new:Npn \clist_map_function:NN #1#2{
  \clist_if_empty:NF #1
  {
    \exp_after:NN \clist_map_function_aux:Nw
    \exp_after:NN #2 #1 , \q_recursion_tail , \q_recursion_stop
  }
}
\def_new:Npn \clist_map_function:cN{\exp_args:Nc\clist_map_function:NN}
\def_new:Npn \clist_map_function:nN #1#2{
  \tlist_if_blank:nF {#1}
  { \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \q_recursion_stop }
}
\def_long_new:Npn \clist_map_function_aux:Nw #1#2,{
  \quark_if_recursion_tail_stop:n{#2}
  #1{#2}
  \clist_map_function_aux:Nw #1
}
\let_new:NN \clist_map_break:w \use_none_delimit_by_q_recursion_stop:w
\int_new:N \g_clist_inline_level_int
\def_long_new:Npn \clist_map_inline:Nn #1#2{
  \clist_if_empty:NF #1
  {
    \int_gincr:N \g_clist_inline_level_int
    \gdef_long:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
    ##1{#2}
    \exp_args:NcE \clist_map_function_aux:Nw
    {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
    #1 , \q_recursion_tail , \q_recursion_stop
    \int_gdecr:N \g_clist_inline_level_int
  }
}
\def_new:Npn \clist_map_inline:cn{\exp_args:Nc\clist_map_inline:Nn}
\def_long_new:Npn \clist_map_inline:nn #1#2{
  \tlist_if_empty:nF {#1}
  {
    \int_gincr:N \g_clist_inline_level_int
    \gdef_long:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
    ##1{#2}
    \exp_args:Nc \clist_map_function_aux:Nw
    {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
    #1 , \q_recursion_tail , \q_recursion_stop
    \int_gdecr:N \g_clist_inline_level_int
  }
}
\def_new:Npn \clist_map_variable:nNn #1#2#3{
  \tlist_if_empty:nF{#1}
  {
    \clist_map_variable_aux:Nnw #2 {#3} #1
    , \q_recursion_tail , \q_recursion_stop
  }
}
\def_new:Npn \clist_map_variable:NNn {\exp_args:No \clist_map_variable:nNn}
\def_new:Npn \clist_map_variable:cNn {\exp_args:Nc \clist_map_variable:NNn}
\def_new:Npn \clist_map_variable_aux:Nnw #1#2#3,{
  \def:Npn #1{#3}
  \quark_if_recursion_tail_stop:N #1
  #2 \clist_map_variable_aux:Nnw #1{#2}
}
\def_new:Npn \clist_concat_aux:NNNN #1#2#3#4{
  \toks_set:No \l_tmpa_toks {#3}
  \toks_set:No \l_tmpb_toks {#4}
  #1 #2 {
    \toks_use:N \l_tmpa_toks
    \toks_if_empty:NF \l_tmpa_toks {\toks_if_empty:NF \l_tmpb_toks ,}
    \toks_use:N \l_tmpb_toks
  }
}
\def_new:Npn \clist_concat:NNN {\clist_concat_aux:NNNN \tlp_set:Nx}
\def_new:Npn \clist_gconcat:NNN {\clist_concat_aux:NNNN \tlp_gset:Nx}
\def_new:Npn \clist_gconcat:NNc{\exp_args:Nnnc\clist_gconcat:NNN}
\def_new:Npn \clist_gconcat:ccc{\exp_args:Nccc\clist_gconcat:NNN}
\def:Npn \clist_remove_duplicates_aux:NN #1#2 {
  \clist_clear:N \l_clist_remove_duplicates_clist
  \clist_map_function:NN #2 \clist_remove_duplicates_aux:n
  #1 #2 \l_clist_remove_duplicates_clist
}
\def:Npn \clist_remove_duplicates_aux:n #1 {
  \clist_if_in:NnTF \l_clist_remove_duplicates_clist {#1} {}
  {\clist_put_right:Nn \l_clist_remove_duplicates_clist {#1}}
}
\def_new:Npn \clist_remove_duplicates:N {
  \clist_remove_duplicates_aux:NN \clist_set_eq:NN
}
\def_new:Npn \clist_gremove_duplicates:N {
  \clist_remove_duplicates_aux:NN \clist_gset_eq:NN
}
\clist_new:N \l_clist_remove_duplicates_clist
\def_new:Npn \clist_use:N #1 {
  \if_meaning:NN #1 \scan_stop:
    \err_latex_bug:x {Comma~list~ `\token_to_string:N #1'~
                      has~ an~ erroneous~ structure!}
  \else:
    \exp_after:NN #1
  \fi:
}
\def_new:Npn \clist_use:c {\exp_args:Nc \clist_use:N}
\def_new:Npn \clist_if_in:NnTF #1#2{
  \def:Npn \tmp:w ##1 ,#2, ##2##3\q_stop{
    \if_meaning:NN\q_no_value##2
      \exp_after:NN\use_arg_ii:nn
    \else:
      \exp_after:NN\use_arg_i:nn
    \fi:
  }
  \exp_after:NN \tmp:w
  \exp_after:NN , #1, #2, \q_no_value \q_stop
}
\def_new:Npn \clist_if_in:NoTF {\exp_args:NNo \clist_if_in:NnTF}
\def_new:Npn \clist_if_in:coTF {\exp_args:Nco \clist_if_in:NnTF}
\def_new:Npn \clist_if_in:cnTF {\exp_args:Nc \clist_if_in:NnTF}
\let_new:NN \clist_push:Nn \clist_put_left:Nn
\let_new:NN \clist_push:No \clist_put_left:No
\let_new:NN \clist_push:cn \clist_put_left:cn
\def_new:Npn \clist_pop:NN {\clist_pop_aux:nnNN \tlp_set:Nn \tlp_set:Nn}
\def_new:Npn \clist_pop:cN {\exp_args:Nc \clist_pop:NN}
\let_new:NN \clist_gpush:Nn \clist_gput_left:Nn
\def_new:Npn \clist_gpush:No {\exp_args:NNo \clist_gpush:Nn}
\def_new:Npn \clist_gpush:cn {\exp_args:Nc \clist_gpush:Nn}
\def_new:Npn \clist_gpop:NN {\clist_pop_aux:nnNN \tlp_gset:Nn \tlp_set:Nn}
\def_new:Npn \clist_gpop:cN {\exp_args:Nc \clist_gpop:NN}
\let_new:NN \clist_top:NN \clist_get:NN
\let_new:NN \clist_top:cN \clist_get:cN
%% 
%%
%% End of file `l3clist.sty'.
