%%
%% This is file `l3prg.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3prg.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: l3prg.dtx Copyright (C) 2005-2011 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: l3prg.dtx 3490 2012-03-04 01:00:53Z bruno $
  {L3 Experimental control structures}
%%
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\package_check_loaded_expl:
\tex_let:D \if_bool:N          \tex_ifodd:D
\tex_let:D \if_predicate:w     \tex_ifodd:D
\cs_new_protected:Npn \bool_new:N #1 { \cs_new_eq:NN #1 \c_false_bool }
\cs_generate_variant:Nn \bool_new:N { c }
\cs_new_protected:Npn \bool_set_true:N #1
  { \cs_set_eq:NN #1 \c_true_bool }
\cs_new_protected:Npn \bool_set_false:N #1
  { \cs_set_eq:NN #1 \c_false_bool }
\cs_new_protected:Npn \bool_gset_true:N #1
  { \cs_gset_eq:NN #1 \c_true_bool }
\cs_new_protected:Npn \bool_gset_false:N #1
  { \cs_gset_eq:NN #1 \c_false_bool }
\cs_generate_variant:Nn \bool_set_true:N   { c }
\cs_generate_variant:Nn \bool_set_false:N  { c }
\cs_generate_variant:Nn \bool_gset_true:N  { c }
\cs_generate_variant:Nn \bool_gset_false:N { c }
\cs_new_eq:NN \bool_set_eq:NN  \cs_set_eq:NN
\cs_new_eq:NN \bool_set_eq:Nc  \cs_set_eq:Nc
\cs_new_eq:NN \bool_set_eq:cN  \cs_set_eq:cN
\cs_new_eq:NN \bool_set_eq:cc  \cs_set_eq:cc
\cs_new_eq:NN \bool_gset_eq:NN \cs_gset_eq:NN
\cs_new_eq:NN \bool_gset_eq:Nc \cs_gset_eq:Nc
\cs_new_eq:NN \bool_gset_eq:cN \cs_gset_eq:cN
\cs_new_eq:NN \bool_gset_eq:cc \cs_gset_eq:cc
\cs_new_protected:Npn \bool_set:Nn #1#2
  { \tex_chardef:D #1 = \bool_if_p:n {#2} }
\cs_new_protected:Npn \bool_gset:Nn #1#2
  { \tex_global:D \tex_chardef:D #1 = \bool_if_p:n {#2} }
\cs_generate_variant:Nn \bool_set:Nn  { c }
\cs_generate_variant:Nn \bool_gset:Nn { c }
\prg_new_conditional:Npnn \bool_if:N #1 { p , T , F , TF }
  {
    \if_meaning:w \c_true_bool #1
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
\cs_generate_variant:Nn \bool_if_p:N { c }
\cs_generate_variant:Nn \bool_if:NT  { c }
\cs_generate_variant:Nn \bool_if:NF  { c }
\cs_generate_variant:Nn \bool_if:NTF { c }
\cs_new_protected:Npn \bool_show:N #1
  {
    \bool_if_exist:NTF #1
      { \bool_show:n {#1} }
      {
        \msg_kernel_error:nnx { kernel } { variable-not-defined }
          { \token_to_str:N #1 }
      }
  }
\cs_new_protected:Npn \bool_show:n #1
  {
    \bool_if:nTF {#1}
      { \msg_aux_show:x { > true } }
      { \msg_aux_show:x { > false } }
  }
\cs_generate_variant:Nn \bool_show:N { c }
\bool_new:N \l_tmpa_bool
\bool_new:N \g_tmpa_bool
\cs_new_eq:NN \bool_if_exist:NTF \cs_if_exist:NTF
\cs_new_eq:NN \bool_if_exist:NT  \cs_if_exist:NT
\cs_new_eq:NN \bool_if_exist:NF  \cs_if_exist:NF
\cs_new_eq:NN \bool_if_exist_p:N \cs_if_exist_p:N
\cs_new_eq:NN \bool_if_exist:cTF \cs_if_exist:cTF
\cs_new_eq:NN \bool_if_exist:cT  \cs_if_exist:cT
\cs_new_eq:NN \bool_if_exist:cF  \cs_if_exist:cF
\cs_new_eq:NN \bool_if_exist_p:c \cs_if_exist_p:c
\prg_new_conditional:Npnn \bool_if:n #1 { T , F , TF }
  {
    \if_predicate:w \bool_if_p:n {#1}
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
\cs_new:Npn \bool_if_p:n #1
  {
    \group_align_safe_begin:
    \bool_get_next:N ( #1 ) S
  }
\cs_new:Npn \bool_get_next:N #1
  {
    \use:c
      {
        bool_
        \if_meaning:w !#1 ! \else: \if_meaning:w (#1 ( \else: p \fi: \fi:
        :w
      }
      #1
  }
\cs_new:Npn \bool_get_not_next:N #1
  {
    \use:c
      {
      bool_not_
      \if_meaning:w !#1 ! \else: \if_meaning:w (#1 ( \else: p \fi: \fi:
      :w
      }
        #1
  }
\cs_new:Npn \bool_get_next:NN #1#2 { \bool_get_next:N #2 }
\cs_new:Npn \bool_get_not_next:NN #1#2 { \bool_get_not_next:N #2 }
\cs_new:cpn { bool_!:w } #1#2
  {
    \if_meaning:w ( #2
      \exp_after:wN \bool_Not:w
    \else:
      \if_meaning:w ! #2
        \exp_after:wN \exp_after:wN \exp_after:wN \bool_get_next:NN
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN \bool_Not:N
      \fi:
    \fi:
    #2
  }
\cs_new:cpn { bool_not_!:w } #1#2
  {
    \if_meaning:w ( #2
      \exp_after:wN \bool_not_Not:w
    \else:
      \if_meaning:w ! #2
        \exp_after:wN \exp_after:wN \exp_after:wN \bool_get_not_next:NN
      \else:
        \exp_after:wN \exp_after:wN \exp_after:wN \bool_not_Not:N
      \fi:
    \fi:
    #2
  }
\cs_new:Npn \bool_Not:w { \exp_after:wN \int_value:w \bool_get_not_next:N }
\cs_new:Npn \bool_not_Not:w { \exp_after:wN \int_value:w \bool_get_next:N }
\cs_new:Npn \bool_Not:N #1
  {
    \exp_after:wN \bool_p:w
    \if_meaning:w #1 \c_true_bool
      \c_false_bool
    \else:
      \c_true_bool
    \fi:
  }
\cs_new:Npn \bool_not_Not:N #1
  {
    \exp_after:wN \bool_p:w
    \if_meaning:w #1 \c_true_bool
      \c_true_bool
    \else:
      \c_false_bool
    \fi:
  }
\cs_new:cpn { bool_(:w } #1
  { \exp_after:wN  \bool_cleanup:N \int_value:w \bool_get_next:N }
\cs_new:cpn { bool_not_(:w } #1
  { \exp_after:wN  \bool_not_cleanup:N \int_value:w \bool_get_next:N }
\cs_new:cpn { bool_p:w } { \exp_after:wN \bool_cleanup:N \int_value:w  }
\cs_new:cpn { bool_not_p:w } {\exp_after:wN \bool_not_cleanup:N \int_value:w }
\cs_new:Npn \bool_cleanup:N #1
  {
    \exp_after:wN \bool_choose:NN \exp_after:wN #1
    \int_to_roman:w - `\q
  }
\cs_new:Npn \bool_not_cleanup:N #1
  {
    \exp_after:wN \bool_not_choose:NN \exp_after:wN #1
    \int_to_roman:w - `\q
  }
\cs_new:Npn \bool_choose:NN #1#2 { \use:c { bool_ #2 _ #1 :w } }
\cs_new:Npn \bool_not_choose:NN #1#2 { \use:c { bool_not_ #2 _ #1 :w } }
\cs_new_nopar:cpn { bool_&_1:w } & { \bool_get_next:N }
\cs_new_nopar:cpn { bool_|_0:w } | { \bool_get_next:N }
\cs_new_nopar:cpn { bool_not_&_0:w } & { \bool_get_next:N }
\cs_new_nopar:cpn { bool_not_|_1:w } | { \bool_get_next:N }
\cs_new_nopar:cpn { bool_)_0:w } { \c_false_bool }
\cs_new_nopar:cpn { bool_)_1:w } { \c_true_bool }
\cs_new_nopar:cpn { bool_not_)_0:w } { \c_true_bool }
\cs_new_nopar:cpn { bool_not_)_1:w } { \c_false_bool }
\cs_new_nopar:cpn { bool_S_0:w } { \group_align_safe_end: \c_false_bool }
\cs_new_nopar:cpn { bool_S_1:w } { \group_align_safe_end: \c_true_bool }
\cs_new_nopar:cpn { bool_&_0:w } & { \bool_eval_skip_to_end:Nw \c_false_bool }
\cs_new_nopar:cpn { bool_|_1:w } | { \bool_eval_skip_to_end:Nw \c_true_bool }
\cs_new_nopar:cpn { bool_not_&_1:w } &
  { \bool_eval_skip_to_end:Nw \c_false_bool }
\cs_new_nopar:cpn { bool_not_|_0:w } |
  { \bool_eval_skip_to_end:Nw \c_true_bool }
%% (
\cs_new:Npn \bool_eval_skip_to_end:Nw #1#2 )
  {
    \bool_eval_skip_to_end_aux:Nw #1#2 ( % )
    \q_no_value \q_stop
    {#2}
  }
\cs_new:Npn \bool_eval_skip_to_end_aux:Nw #1#2 ( #3#4 \q_stop #5 % )
  {
    \quark_if_no_value:NTF #3
    {#1}
    { \bool_eval_skip_to_end_aux_ii:Nw #1 #5 }
  }
\cs_new:Npn \bool_eval_skip_to_end_aux_ii:Nw #1#2 ( #3 )
  { % (
    \bool_eval_skip_to_end:Nw #1#3 )
  }
\cs_new:Npn \bool_not_p:n #1 { \bool_if_p:n { ! ( #1 ) } }
\cs_new:Npn \bool_xor_p:nn #1#2
  {
    \int_compare:nNnTF { \bool_if_p:n {#1} } = { \bool_if_p:n {#2} }
      \c_false_bool
      \c_true_bool
  }
\cs_new:Npn \bool_while_do:Nn #1#2
  { \bool_if:NT #1 { #2 \bool_while_do:Nn #1 {#2} } }
\cs_new:Npn \bool_until_do:Nn #1#2
  { \bool_if:NF #1 { #2 \bool_until_do:Nn #1 {#2} } }
\cs_generate_variant:Nn \bool_while_do:Nn { c }
\cs_generate_variant:Nn \bool_until_do:Nn { c }
\cs_new:Npn \bool_do_while:Nn #1#2
  { #2 \bool_if:NT #1 { \bool_do_while:Nn #1 {#2} } }
\cs_new:Npn \bool_do_until:Nn #1#2
  { #2 \bool_if:NF #1 { \bool_do_until:Nn #1 {#2} } }
\cs_generate_variant:Nn \bool_do_while:Nn { c }
\cs_generate_variant:Nn \bool_do_until:Nn { c }
\cs_new:Npn \bool_while_do:nn #1#2
  {
    \bool_if:nT {#1}
      {
        #2
        \bool_while_do:nn {#1} {#2}
      }
  }
\cs_new:Npn \bool_do_while:nn #1#2
  {
    #2
    \bool_if:nT {#1} { \bool_do_while:nn {#1} {#2} }
  }
\cs_new:Npn \bool_until_do:nn #1#2
  {
    \bool_if:nF {#1}
      {
        #2
        \bool_until_do:nn {#1} {#2}
      }
  }
\cs_new:Npn \bool_do_until:nn #1#2
  {
    #2
    \bool_if:nF {#1} { \bool_do_until:nn {#1} {#2}  }
  }
\cs_new:Npn \prg_case_end:nw #1 #2 \q_recursion_stop { \c_zero #1 }
\cs_new:Npn \prg_case_int:nnn #1
  {
    \tex_romannumeral:D
    \exp_args:Nf \prg_case_int_aux:nnn { \int_eval:n {#1} }
  }
\cs_new:Npn \prg_case_int_aux:nnn #1 #2 #3
  { \prg_case_int_aux:nw {#1} #2 {#1} {#3} \q_recursion_stop }
\cs_new:Npn \prg_case_int_aux:nw #1#2#3
  {
    \int_compare:nNnTF {#1} = {#2}
      { \prg_case_end:nw {#3} }
      { \prg_case_int_aux:nw {#1} }
  }
\cs_new:Npn \prg_case_dim:nnn #1
  {
    \tex_romannumeral:D
    \exp_args:Nf \prg_case_dim_aux:nnn { \dim_eval:n {#1} }
  }
\cs_new:Npn \prg_case_dim_aux:nnn #1 #2 #3
  { \prg_case_dim_aux:nw {#1} #2 {#1} {#3} \q_recursion_stop }
\cs_new:Npn \prg_case_dim_aux:nw #1#2#3
  {
    \dim_compare:nNnTF {#1} = {#2}
      { \prg_case_end:nw {#3} }
      { \prg_case_dim_aux:nw {#1} }
  }
\cs_new:Npn \prg_case_str:nnn #1#2#3
  {
    \tex_romannumeral:D
    \prg_case_str_aux:nw {#1} #2 {#1} {#3} \q_recursion_stop
  }
\cs_new:Npn \prg_case_str_aux:nw #1#2#3
  {
    \str_if_eq:nnTF {#1} {#2}
      { \prg_case_end:nw {#3} }
      { \prg_case_str_aux:nw {#1} }
  }
\cs_generate_variant:Nn \prg_case_str:nnn { o }
\cs_new:Npn \prg_case_str:xxn #1#2#3
  {
    \tex_romannumeral:D
    \prg_case_str_x_aux:nw {#1} #2 {#1} {#3} \q_recursion_stop
  }
\cs_new:Npn \prg_case_str_x_aux:nw #1#2#3
  {
    \str_if_eq:xxTF {#1} {#2}
      { \prg_case_end:nw {#3} }
      { \prg_case_str_x_aux:nw {#1} }
  }
\cs_new:Npn \prg_case_tl:Nnn #1#2#3
  {
    \tex_romannumeral:D
    \prg_case_tl_aux:Nw #1 #2 #1 {#3} \q_recursion_stop
  }
\cs_new:Npn \prg_case_tl_aux:Nw #1#2#3
  {
    \tl_if_eq:NNTF #1 #2
      { \prg_case_end:nw {#3} }
      { \prg_case_tl_aux:Nw #1 }
  }
\cs_generate_variant:Nn \prg_case_tl:Nnn { c }
\cs_new:Npn \prg_replicate:nn #1
  {
    \int_to_roman:w
      \exp_after:wN \prg_replicate_first_aux:N
        \int_value:w \int_eval:w #1 \int_eval_end:
      \cs_end:
  }
\cs_new:Npn \prg_replicate_aux:N #1
  { \cs:w prg_replicate_#1 :n \prg_replicate_aux:N }
\cs_new:Npn \prg_replicate_first_aux:N #1
  { \cs:w prg_replicate_first_ #1 :n \prg_replicate_aux:N }
\cs_new:Npn \prg_replicate_ :n #1 { \cs_end: }
\cs_new:cpn { prg_replicate_0:n } #1 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} }
\cs_new:cpn { prg_replicate_1:n } #1 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1 }
\cs_new:cpn { prg_replicate_2:n } #1 { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1 }
\cs_new:cpn { prg_replicate_3:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1 }
\cs_new:cpn { prg_replicate_4:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1 }
\cs_new:cpn { prg_replicate_5:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1 }
\cs_new:cpn { prg_replicate_6:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_7:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_8:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_9:n } #1
  { \cs_end: {#1#1#1#1#1#1#1#1#1#1} #1#1#1#1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_first_-:n } #1
  { \c_zero \msg_expandable_kernel_error:nn { prg } { replicate-neg } }
\cs_new:cpn { prg_replicate_first_0:n } #1 { \c_zero }
\cs_new:cpn { prg_replicate_first_1:n } #1 { \c_zero #1 }
\cs_new:cpn { prg_replicate_first_2:n } #1 { \c_zero #1#1 }
\cs_new:cpn { prg_replicate_first_3:n } #1 { \c_zero #1#1#1 }
\cs_new:cpn { prg_replicate_first_4:n } #1 { \c_zero #1#1#1#1 }
\cs_new:cpn { prg_replicate_first_5:n } #1 { \c_zero #1#1#1#1#1 }
\cs_new:cpn { prg_replicate_first_6:n } #1 { \c_zero #1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_first_7:n } #1 { \c_zero #1#1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_first_8:n } #1 { \c_zero #1#1#1#1#1#1#1#1 }
\cs_new:cpn { prg_replicate_first_9:n } #1 { \c_zero #1#1#1#1#1#1#1#1#1 }
\cs_new:Npn \prg_stepwise_function:nnnN #1#2#3#4
  {
    \prg_stepwise_aux:nnnN {#1} {#2} {#3} #4
    \prg_break_point:n { }
  }
\cs_new:Npn \prg_stepwise_aux:nnnN #1#2#3#4
  {
    \int_compare:nNnTF {#2} > \c_zero
      { \exp_args:NNf \prg_stepwise_aux:NnnnN > }
      {
        \int_compare:nNnTF {#2} = \c_zero
          {
            \msg_expandable_kernel_error:nnn { prg } { zero-step } {#4}
            \prg_map_break:
          }
          { \exp_args:NNf \prg_stepwise_aux:NnnnN < }
      }
      { \int_eval:n {#1} } {#2} {#3} #4
  }
\cs_new:Npn \prg_stepwise_aux:NnnnN #1#2#3#4#5
  {
    \int_compare:nNnF {#2} #1 {#4}
      {
        #5 {#2}
        \exp_args:NNf \prg_stepwise_aux:NnnnN
          #1 { \int_eval:n { #2 + #3 } } {#3} {#4} #5
      }
  }
\cs_new_protected:Npn \prg_stepwise_inline:nnnn
  {
    \exp_args:NNc \prg_stepwise_aux:NNnnnn
      \cs_gset_nopar:Npn
      { g_prg_stepwise_ \int_use:N \g_prg_map_int :n }
  }
\cs_new_protected:Npn \prg_stepwise_variable:nnnNn #1#2#3#4#5
  {
    \exp_args:NNc \prg_stepwise_aux:NNnnnn
      \cs_gset_nopar:Npx
      { g_prg_stepwise_ \int_use:N \g_prg_map_int :n }
      {#1}{#2}{#3}
      {
        \tl_set:Nn \exp_not:N #4 {##1}
        \exp_not:n {#5}
      }
  }
\cs_new_protected:Npn \prg_stepwise_aux:NNnnnn #1#2#3#4#5#6
  {
    #1 #2 ##1 {#6}
    \int_gincr:N \g_prg_map_int
    \prg_stepwise_aux:nnnN {#3} {#4} {#5} #2
    \prg_break_point:n { \int_gdecr:N \g_prg_map_int }
  }
\prg_new_conditional:Npnn \mode_if_vertical: { p , T , F , TF }
  { \if_mode_vertical: \prg_return_true: \else: \prg_return_false: \fi: }
\prg_new_conditional:Npnn \mode_if_horizontal: { p , T , F , TF }
  { \if_mode_horizontal: \prg_return_true: \else: \prg_return_false: \fi: }
\prg_new_conditional:Npnn \mode_if_inner: { p , T , F , TF }
  { \if_mode_inner: \prg_return_true: \else: \prg_return_false: \fi: }
\prg_new_conditional:Npnn \mode_if_math: { p , T , F , TF }
  { \if_mode_math: \prg_return_true: \else: \prg_return_false: \fi: }
\cs_new_nopar:Npn \group_align_safe_begin:
  { \if_int_compare:w \if_false: { \fi: `} = \c_zero \fi: }
\cs_new_nopar:Npn \group_align_safe_end:
  { \if_int_compare:w `{ = \c_zero } \fi: }
\cs_new_protected_nopar:Npn \scan_align_safe_stop: { }
\group_begin:
  \tex_lccode:D `\& = `\g \scan_stop:
  \tex_catcode:D `\& = \c_twelve
\tl_to_lowercase:n
  {
    \group_end:
    \cs_new:Npn \prg_variable_get_scope:N #1
      {
        \exp_after:wN \exp_after:wN
        \exp_after:wN \prg_variable_get_scope_aux:w
          \cs_to_str:N #1 \exp_stop_f: \q_stop
      }
    \cs_new:Npn \prg_variable_get_scope_aux:w #1#2 \q_stop
      { \token_if_eq_meaning:NNT & #1 { g } }
  }
\group_begin:
  \tex_lccode:D `\& = `\_ \scan_stop:
  \tex_catcode:D `\& = \c_twelve
\tl_to_lowercase:n
  {
    \group_end:
    \cs_new:Npn \prg_variable_get_type:N #1
      {
        \exp_after:wN \prg_variable_get_type_aux:w
          \token_to_str:N #1 & a \q_stop
      }
    \cs_new:Npn \prg_variable_get_type_aux:w #1 & #2#3 \q_stop
      {
        \token_if_eq_meaning:NNTF a #2
          {#1}
          { \prg_variable_get_type_aux:w #2#3 \q_stop }
      }
  }
\int_new:N \g_prg_map_int
\cs_new_protected:Npn \prg_define_quicksort:nnn #1#2#3 {
  \cs_set:cpx{#1_quicksort:n}##1{
    \exp_not:c{#1_quicksort_start_partition:w} ##1
    \exp_not:n{#2\q_nil#3\q_stop}
  }
  \cs_set:cpx{#1_quicksort_braced:n}##1{
    \exp_not:c{#1_quicksort_start_partition_braced:n} ##1
    \exp_not:N\q_nil\exp_not:N\q_stop
  }
  \cs_set:cpx {#1_quicksort_start_partition:w} #2 ##1 #3{
    \exp_not:N \quark_if_nil:nT {##1}\exp_not:N \use_none_delimit_by_q_stop:w
    \exp_not:c{#1_quicksort_do_partition_i:nnnw} {##1}{}{}
  }
  \cs_set:cpx {#1_quicksort_start_partition_braced:n} ##1 {
    \exp_not:N \quark_if_nil:nT {##1}\exp_not:N \use_none_delimit_by_q_stop:w
    \exp_not:c{#1_quicksort_do_partition_i_braced:nnnn} {##1}{}{}
  }
  \cs_set:cpx {#1_quicksort_do_partition_i:nnnw} ##1##2##3 #2 ##4 #3 {
    \exp_not:N \quark_if_nil:nTF {##4} \exp_not:c {#1_do_quicksort_braced:nnnnw}
    {
      \exp_not:c{#1_quicksort_compare:nnTF}{##1}{##4}
      \exp_not:c{#1_quicksort_partition_greater_ii:nnnn}
      \exp_not:c{#1_quicksort_partition_less_ii:nnnn}
    }
    {##1}{##2}{##3}{##4}
  }
  \cs_set:cpx {#1_quicksort_do_partition_i_braced:nnnn} ##1##2##3##4 {
    \exp_not:N \quark_if_nil:nTF {##4} \exp_not:c {#1_do_quicksort_braced:nnnnw}
    {
      \exp_not:c{#1_quicksort_compare:nnTF}{##1}{##4}
      \exp_not:c{#1_quicksort_partition_greater_ii_braced:nnnn}
      \exp_not:c{#1_quicksort_partition_less_ii_braced:nnnn}
    }
    {##1}{##2}{##3}{##4}
  }
  \cs_set:cpx {#1_quicksort_do_partition_ii:nnnw} ##1##2##3 #2 ##4 #3 {
    \exp_not:N \quark_if_nil:nTF {##4} \exp_not:c {#1_do_quicksort_braced:nnnnw}
    {
      \exp_not:c{#1_quicksort_compare:nnTF}{##4}{##1}
      \exp_not:c{#1_quicksort_partition_less_i:nnnn}
      \exp_not:c{#1_quicksort_partition_greater_i:nnnn}
    }
    {##1}{##2}{##3}{##4}
  }
  \cs_set:cpx {#1_quicksort_do_partition_ii_braced:nnnn} ##1##2##3##4 {
    \exp_not:N \quark_if_nil:nTF {##4} \exp_not:c {#1_do_quicksort_braced:nnnnw}
    {
      \exp_not:c{#1_quicksort_compare:nnTF}{##4}{##1}
      \exp_not:c{#1_quicksort_partition_less_i_braced:nnnn}
      \exp_not:c{#1_quicksort_partition_greater_i_braced:nnnn}
    }
    {##1}{##2}{##3}{##4}
  }
  \cs_set:cpx {#1_quicksort_partition_less_i:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_i:nnnw}{##1}{##2}{{##4}##3}}
  \cs_set:cpx {#1_quicksort_partition_less_ii:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_ii:nnnw}{##1}{##2}{##3{##4}}}
  \cs_set:cpx {#1_quicksort_partition_greater_i:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_i:nnnw}{##1}{{##4}##2}{##3}}
  \cs_set:cpx {#1_quicksort_partition_greater_ii:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_ii:nnnw}{##1}{##2{##4}}{##3}}
  \cs_set:cpx {#1_quicksort_partition_less_i_braced:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_i_braced:nnnn}{##1}{##2}{{##4}##3}}
  \cs_set:cpx {#1_quicksort_partition_less_ii_braced:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_ii_braced:nnnn}{##1}{##2}{##3{##4}}}
  \cs_set:cpx {#1_quicksort_partition_greater_i_braced:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_i_braced:nnnn}{##1}{{##4}##2}{##3}}
  \cs_set:cpx {#1_quicksort_partition_greater_ii_braced:nnnn} ##1##2##3##4{
    \exp_not:c{#1_quicksort_do_partition_ii_braced:nnnn}{##1}{##2{##4}}{##3}}
  \cs_set:cpx {#1_do_quicksort_braced:nnnnw} ##1##2##3##4\q_stop {
    \exp_not:c{#1_quicksort_braced:n}{##2}
    \exp_not:c{#1_quicksort_function:n}{##1}
    \exp_not:c{#1_quicksort_braced:n}{##3}
  }
}
\prg_define_quicksort:nnn {prg}{}{}
\cs_set:Npn \prg_quicksort_function:n {\ERROR}
\cs_set:Npn \prg_quicksort_compare:nnTF {\ERROR}
%% 
%%
%% End of file `l3prg.sty'.
