%%
%% This is file `l3seq.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3seq.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: l3seq.dtx Copyright (C) 1990-2013 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{l3bootstrap}
\GetIdInfo$Id: l3seq.dtx 4434 2013-01-12 09:33:40Z bruno $
  {L3 Sequences and stacks}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\__expl_package_check:
\cs_new:Npn \__seq_item:n
  {
    \__msg_kernel_expandable_error:nn { kernel } { misused-sequence }
    \use_none:n
  }
\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
\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
\cs_new_eq:NN \seq_set_eq:cc  \tl_set_eq:cc
\cs_new_eq:NN \seq_gset_eq:NN \tl_gset_eq:NN
\cs_new_eq:NN \seq_gset_eq:Nc \tl_gset_eq:Nc
\cs_new_eq:NN \seq_gset_eq:cN \tl_gset_eq:cN
\cs_new_eq:NN \seq_gset_eq:cc \tl_gset_eq:cc
\cs_new_protected_nopar:Npn \seq_set_split:Nnn
  { \__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
  {
    \tl_if_empty:nTF {#3}
      { #1 #2 { \tl_map_function:nN {#4} \__seq_wrap_item:n } }
      {
        \tl_set:Nn \l__seq_internal_a_tl
          {
            \__seq_set_split_auxi:w \prg_do_nothing:
            #4
            \__seq_set_split_end:
          }
        \tl_replace_all:Nnn \l__seq_internal_a_tl { #3 }
          {
            \__seq_set_split_end:
            \__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 }
      }
  }
\cs_new:Npn \__seq_set_split_auxi:w #1 \__seq_set_split_end:
  {
    \exp_not:N \__seq_set_split_auxii:w
    \exp_args:No \tl_trim_spaces:n {#1}
    \exp_not:N \__seq_set_split_end:
  }
\cs_new:Npn \__seq_set_split_auxii:w #1 \__seq_set_split_end:
  { \__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
\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} } }
\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_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_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
  { \__seq_remove_duplicates:NN \seq_set_eq:NN }
\cs_new_protected:Npn \seq_gremove_duplicates:N
  { \__seq_remove_duplicates:NN \seq_gset_eq:NN }
\cs_new_protected:Npn \__seq_remove_duplicates:NN #1#2
  {
    \seq_clear:N \l__seq_remove_seq
    \seq_map_inline:Nn #2
      {
        \seq_if_in:NnF \l__seq_remove_seq {##1}
          { \seq_put_right:Nn \l__seq_remove_seq {##1} }
      }
    #1 #2 \l__seq_remove_seq
  }
\cs_generate_variant:Nn \seq_remove_duplicates:N  { c }
\cs_generate_variant:Nn \seq_gremove_duplicates:N { c }
\cs_new_protected:Npn \seq_remove_all:Nn
  { \__seq_remove_all_aux:NNn \tl_set:Nx }
\cs_new_protected:Npn \seq_gremove_all:Nn
  { \__seq_remove_all_aux:NNn \tl_gset:Nx }
\cs_new_protected:Npn \__seq_remove_all_aux:NNn #1#2#3
  {
    \__seq_push_item_def:n
      {
        \str_if_eq:nnT {##1} {#3}
          {
            \if_false: { \fi: }
            \tl_set:Nn \l__seq_internal_b_tl {##1}
            #1 #2
               { \if_false: } \fi:
                 \exp_not:o {#2}
                 \tl_if_eq:NNT \l__seq_internal_a_tl \l__seq_internal_b_tl
                   { \use_none:nn }
          }
        \__seq_wrap_item:n {##1}
      }
    \tl_set:Nn \l__seq_internal_a_tl {#3}
    #1 #2 {#2}
    \__seq_pop_item_def:
  }
\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_protected_conditional:Npnn \seq_if_in:Nn #1#2
  { T , F , TF }
  {
    \group_begin:
      \tl_set:Nn \l__seq_internal_a_tl {#2}
      \cs_set_protected:Npn \__seq_item:n ##1
        {
          \tl_set:Nn \l__seq_internal_b_tl {##1}
          \if_meaning:w \l__seq_internal_a_tl \l__seq_internal_b_tl
            \exp_after:wN \__seq_if_in:
          \fi:
        }
      #1
    \group_end:
    \prg_return_false:
    \__prg_break_point:
  }
\cs_new_nopar:Npn \__seq_if_in:
  { \__prg_break:n { \group_end: \prg_return_true: } }
\cs_generate_variant:Nn \seq_if_in:NnT  {     NV , Nv , No , Nx }
\cs_generate_variant:Nn \seq_if_in:NnT  { c , cV , cv , co , cx }
\cs_generate_variant:Nn \seq_if_in:NnF  {     NV , Nv , No , Nx }
\cs_generate_variant:Nn \seq_if_in:NnF  { c , cV , cv , co , cx }
\cs_generate_variant:Nn \seq_if_in:NnTF {     NV , Nv , No , Nx }
\cs_generate_variant:Nn \seq_if_in:NnTF { c , cV , cv , co , cx }
\cs_new_protected:Npn \__seq_pop:NNNN #1#2#3#4
  {
    \if_meaning:w #3 \c_empty_seq
      \tl_set:Nn #4 { \q_no_value }
    \else:
      #1#2#3#4
    \fi:
  }
\cs_new_protected:Npn \__seq_pop_TF:NNNN #1#2#3#4
  {
    \if_meaning:w #3 \c_empty_seq
      % \tl_set:Nn #4 { \q_no_value }
      \prg_return_false:
    \else:
      #1#2#3#4
      \prg_return_true:
    \fi:
  }
\cs_new_protected:Npn \seq_get_left:NN #1#2
  {
    \tl_set:Nx #2
      {
        \exp_after:wN \__seq_get_left:Nnw
        #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_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
  {
    #3 #4 {#2}
    \tl_set:Nn #5 {#1}
  }
\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_loop:nn
    \exp_after:wN \q_no_value
    #1
    {
      ??
      \tex_afterassignment:D \use_none:n
      \tl_set:Nn #2
    }
  }
\cs_new_protected:Npn \__seq_get_right_loop:nn #1#2
  {
    \use_none:nn #2 {#1}
    \__seq_get_right_loop:nn
  }
\cs_generate_variant:Nn \seq_get_right:NN { c }
\cs_new_protected_nopar:Npn \seq_pop_right:NN
  { \__seq_pop:NNNN \__seq_pop_right_aux:NNN \tl_set:Nx }
\cs_new_protected_nopar:Npn \seq_gpop_right:NN
  { \__seq_pop:NNNN \__seq_pop_right_aux:NNN \tl_gset:Nx }
\cs_new_protected:Npn \__seq_pop_right_aux:NNN #1#2#3
  {
    \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
        #2
        {
          \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_loop:nn #1#2
  {
    #2 { \exp_not:n {#1} }
    \__seq_pop_right_loop:nn
  }
\cs_generate_variant:Nn \seq_pop_right:NN  { c }
\cs_generate_variant:Nn \seq_gpop_right:NN { c }
\prg_new_protected_conditional:Npnn \seq_get_left:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \prg_do_nothing: \seq_get_left:NN #1#2 }
\prg_new_protected_conditional:Npnn \seq_get_right:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \prg_do_nothing: \seq_get_right:NN #1#2 }
\cs_generate_variant:Nn \seq_get_left:NNT   { c }
\cs_generate_variant:Nn \seq_get_left:NNF   { c }
\cs_generate_variant:Nn \seq_get_left:NNTF  { c }
\cs_generate_variant:Nn \seq_get_right:NNT  { c }
\cs_generate_variant:Nn \seq_get_right:NNF  { c }
\cs_generate_variant:Nn \seq_get_right:NNTF { c }
\prg_new_protected_conditional:Npnn \seq_pop_left:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \__seq_pop_left:NNN \tl_set:Nn #1 #2 }
\prg_new_protected_conditional:Npnn \seq_gpop_left:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \__seq_pop_left:NNN \tl_gset:Nn #1 #2 }
\prg_new_protected_conditional:Npnn \seq_pop_right:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \__seq_pop_right_aux:NNN \tl_set:Nx #1 #2 }
\prg_new_protected_conditional:Npnn \seq_gpop_right:NN #1#2 { T , F , TF }
  { \__seq_pop_TF:NNNN \__seq_pop_right_aux:NNN \tl_gset:Nx #1 #2 }
\cs_generate_variant:Nn \seq_pop_left:NNT    { c }
\cs_generate_variant:Nn \seq_pop_left:NNF    { c }
\cs_generate_variant:Nn \seq_pop_left:NNTF   { c }
\cs_generate_variant:Nn \seq_gpop_left:NNT   { c }
\cs_generate_variant:Nn \seq_gpop_left:NNF   { c }
\cs_generate_variant:Nn \seq_gpop_left:NNTF  { c }
\cs_generate_variant:Nn \seq_pop_right:NNT   { c }
\cs_generate_variant:Nn \seq_pop_right:NNF   { c }
\cs_generate_variant:Nn \seq_pop_right:NNTF  { c }
\cs_generate_variant:Nn \seq_gpop_right:NNT  { c }
\cs_generate_variant:Nn \seq_gpop_right:NNF  { c }
\cs_generate_variant:Nn \seq_gpop_right:NNTF { c }
\cs_new_nopar:Npn \seq_map_break:
  { \__prg_map_break:Nn \seq_map_break: { } }
\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:NNn \exp_after:wN #2 #1
      { ? \seq_map_break: } { }
    \__prg_break_point:Nn \seq_map_break: { }
  }
\cs_new:Npn \__seq_map_function:NNn #1#2#3
  {
    \use_none:n #2
    #1 {#3}
    \__seq_map_function:NNn #1
  }
\cs_generate_variant:Nn \seq_map_function:NN { c }
\cs_new_protected:Npn \__seq_push_item_def:n
  {
    \__seq_push_item_def:
    \cs_gset:Npn \__seq_item:n ##1
  }
\cs_new_protected:Npn \__seq_push_item_def:x
  {
    \__seq_push_item_def:
    \cs_gset:Npx \__seq_item:n ##1
  }
\cs_new_protected:Npn \__seq_push_item_def:
  {
    \int_gincr:N \g__prg_map_int
    \cs_gset_eq:cN { __prg_map_ \int_use:N \g__prg_map_int :w }
      \__seq_item:n
  }
\cs_new_protected_nopar:Npn \__seq_pop_item_def:
  {
    \cs_gset_eq:Nc \__seq_item:n
      { __prg_map_ \int_use:N \g__prg_map_int :w }
    \int_gdecr:N \g__prg_map_int
  }
\cs_new_protected:Npn \seq_map_inline:Nn #1#2
  {
    \__seq_push_item_def:n {#2}
    #1
    \__prg_break_point:Nn \seq_map_break: { \__seq_pop_item_def: }
  }
\cs_generate_variant:Nn \seq_map_inline:Nn { c }
\cs_new_protected:Npn \seq_map_variable:NNn #1#2#3
  {
    \__seq_push_item_def:x
      {
        \tl_set:Nn \exp_not:N #2 {##1}
        \exp_not:n {#3}
      }
    #1
    \__prg_break_point:Nn \seq_map_break: { \__seq_pop_item_def: }
  }
\cs_generate_variant:Nn \seq_map_variable:NNn {     Nc }
\cs_generate_variant:Nn \seq_map_variable:NNn { c , cc }
\cs_new:Npn \seq_count:N #1
  {
    \int_eval:n
      {
        0
        \seq_map_function:NN #1 \__seq_count:n
      }
  }
\cs_new:Npn \__seq_count:n #1 { + \c_one }
\cs_generate_variant:Nn \seq_count:N { c }
\cs_new_eq:NN \seq_push:Nn  \seq_put_left:Nn
\cs_new_eq:NN \seq_push:NV  \seq_put_left:NV
\cs_new_eq:NN \seq_push:Nv  \seq_put_left:Nv
\cs_new_eq:NN \seq_push:No  \seq_put_left:No
\cs_new_eq:NN \seq_push:Nx  \seq_put_left:Nx
\cs_new_eq:NN \seq_push:cn  \seq_put_left:cn
\cs_new_eq:NN \seq_push:cV  \seq_put_left:cV
\cs_new_eq:NN \seq_push:cv  \seq_put_left:cv
\cs_new_eq:NN \seq_push:co  \seq_put_left:co
\cs_new_eq:NN \seq_push:cx  \seq_put_left:cx
\cs_new_eq:NN \seq_gpush:Nn \seq_gput_left:Nn
\cs_new_eq:NN \seq_gpush:NV \seq_gput_left:NV
\cs_new_eq:NN \seq_gpush:Nv \seq_gput_left:Nv
\cs_new_eq:NN \seq_gpush:No \seq_gput_left:No
\cs_new_eq:NN \seq_gpush:Nx \seq_gput_left:Nx
\cs_new_eq:NN \seq_gpush:cn \seq_gput_left:cn
\cs_new_eq:NN \seq_gpush:cV \seq_gput_left:cV
\cs_new_eq:NN \seq_gpush:cv \seq_gput_left:cv
\cs_new_eq:NN \seq_gpush:co \seq_gput_left:co
\cs_new_eq:NN \seq_gpush:cx \seq_gput_left:cx
\cs_new_eq:NN \seq_get:NN \seq_get_left:NN
\cs_new_eq:NN \seq_get:cN \seq_get_left:cN
\cs_new_eq:NN \seq_pop:NN \seq_pop_left:NN
\cs_new_eq:NN \seq_pop:cN \seq_pop_left:cN
\cs_new_eq:NN \seq_gpop:NN \seq_gpop_left:NN
\cs_new_eq:NN \seq_gpop:cN \seq_gpop_left:cN
\prg_new_eq_conditional:NNn \seq_get:NN  \seq_get_left:NN  { T , F , TF }
\prg_new_eq_conditional:NNn \seq_get:cN  \seq_get_left:cN  { T , F , TF }
\prg_new_eq_conditional:NNn \seq_pop:NN  \seq_pop_left:NN  { T , F , TF }
\prg_new_eq_conditional:NNn \seq_pop:cN  \seq_pop_left:cN  { T , F , TF }
\prg_new_eq_conditional:NNn \seq_gpop:NN \seq_gpop_left:NN { T , F , TF }
\prg_new_eq_conditional:NNn \seq_gpop:cN \seq_gpop_left:cN { T , F , TF }
\cs_new_protected:Npn \seq_show:N #1
  {
    \__msg_show_variable:Nnn #1 { seq }
      { \seq_map_function:NN #1 \__msg_show_item:n }
  }
\cs_generate_variant:Nn \seq_show:N { c }
\seq_new:N \l_tmpa_seq
\seq_new:N \l_tmpb_seq
\seq_new:N \g_tmpa_seq
\seq_new:N \g_tmpb_seq
%% 
%%
%% End of file `l3seq.sty'.
