%% %% 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 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 LaTeX Project Team. %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} \GetIdInfo$Id: l3prg.dtx 2223 2011-04-09 12:57:14Z will $ {L3 Experimental control structures} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} \package_check_loaded_expl: \prg_set_conditional:Npnn \mode_if_vertical: {p,TF,T,F}{ \if_mode_vertical: \prg_return_true: \else: \prg_return_false: \fi: } \prg_set_conditional:Npnn \mode_if_horizontal: {p,TF,T,F}{ \if_mode_horizontal: \prg_return_true: \else: \prg_return_false: \fi: } \prg_set_conditional:Npnn \mode_if_inner: {p,TF,T,F}{ \if_mode_inner: \prg_return_true: \else: \prg_return_false: \fi: } \prg_set_conditional:Npnn \mode_if_math: {p,TF,T,F}{ \scan_align_safe_stop: \if_mode_math: \prg_return_true: \else: \prg_return_false: \fi: } \cs_new_nopar:Npn \group_align_safe_begin: { \if_false:{\fi:\if_num:w`}=\c_zero\fi:} \cs_new_nopar:Npn \group_align_safe_end: {\if_num:w`{=\c_zero}\fi:} \cs_new_nopar:Npn \scan_align_safe_stop: { \int_compare:nNnT \etex_currentgrouptype:D = \c_six { \int_compare:nNnF \etex_lastnodetype:D = \c_zero { \int_compare:nNnF \etex_lastnodetype:D = \c_seven \scan_stop: } } } \cs_new_nopar:Npn \prg_replicate:nn #1{ \cs:w prg_do_nothing: \exp_after:wN\prg_replicate_first_aux:N \tex_romannumeral:D -`\q \int_eval:n{#1} \cs_end: \cs_end: } \cs_new_nopar:Npn \prg_replicate_aux:N#1{ \cs:w prg_replicate_#1:n\prg_replicate_aux:N } \cs_new_nopar:Npn \prg_replicate_first_aux:N#1{ \cs:w prg_replicate_first_#1:n\prg_replicate_aux:N } \cs_new_nopar:Npn \prg_replicate_ :n #1{}% no, this is not a typo! \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{\cs_end: \ERROR } \cs_new:cpn {prg_replicate_first_0:n}#1{\cs_end: } \cs_new:cpn {prg_replicate_first_1:n}#1{\cs_end: #1} \cs_new:cpn {prg_replicate_first_2:n}#1{\cs_end: #1#1} \cs_new:cpn {prg_replicate_first_3:n}#1{\cs_end: #1#1#1} \cs_new:cpn {prg_replicate_first_4:n}#1{\cs_end: #1#1#1#1} \cs_new:cpn {prg_replicate_first_5:n}#1{\cs_end: #1#1#1#1#1} \cs_new:cpn {prg_replicate_first_6:n}#1{\cs_end: #1#1#1#1#1#1} \cs_new:cpn {prg_replicate_first_7:n}#1{\cs_end: #1#1#1#1#1#1#1} \cs_new:cpn {prg_replicate_first_8:n}#1{\cs_end: #1#1#1#1#1#1#1#1} \cs_new:cpn {prg_replicate_first_9:n}#1{\cs_end: #1#1#1#1#1#1#1#1#1} \cs_new:Npn \prg_stepwise_function:nnnN #1#2{ \int_compare:nNnTF{#2}<\c_zero {\exp_args:Nf\prg_stepwise_function_decr:nnnN } {\exp_args:Nf\prg_stepwise_function_incr:nnnN } {\int_eval:n{#1}}{#2} } \cs_new:Npn \prg_stepwise_function_incr:nnnN #1#2#3#4{ \int_compare:nNnF {#1}>{#3} { #4{#1} \exp_args:Nf \prg_stepwise_function_incr:nnnN {\int_eval:n{#1 + #2}} {#2}{#3}{#4} } } \cs_new:Npn \prg_stepwise_function_decr:nnnN #1#2#3#4{ \int_compare:nNnF {#1}<{#3} { #4{#1} \exp_args:Nf \prg_stepwise_function_decr:nnnN {\int_eval:n{#1 + #2}} {#2}{#3}{#4} } } \cs_new_protected:Npn\prg_stepwise_inline:nnnn #1#2#3#4{ \int_gincr:N \g_prg_inline_level_int \cs_gset_nopar:cpn{prg_stepwise_inline_\int_use:N\g_prg_inline_level_int :n}##1{#4} \int_compare:nNnTF {#2}<\c_zero {\exp_args:Ncf \prg_stepwise_inline_decr:Nnnn } {\exp_args:Ncf \prg_stepwise_inline_incr:Nnnn } {prg_stepwise_inline_\int_use:N\g_prg_inline_level_int :n} {\int_eval:n{#1}} {#2} {#3} \int_gdecr:N \g_prg_inline_level_int } \cs_new:Npn \prg_stepwise_inline_incr:Nnnn #1#2#3#4{ \int_compare:nNnF {#2}>{#4} { #1{#2} \exp_args:NNf \prg_stepwise_inline_incr:Nnnn #1 {\int_eval:n{#2 + #3}} {#3}{#4} } } \cs_new:Npn \prg_stepwise_inline_decr:Nnnn #1#2#3#4{ \int_compare:nNnF {#2}<{#4} { #1{#2} \exp_args:NNf \prg_stepwise_inline_decr:Nnnn #1 {\int_eval:n{#2 + #3}} {#3}{#4} } } \cs_new_protected:Npn \prg_stepwise_variable:nnnNn #1#2 { \int_compare:nNnTF {#2}<\c_zero {\exp_args:Nf\prg_stepwise_variable_decr:nnnNn} {\exp_args:Nf\prg_stepwise_variable_incr:nnnNn} {\int_eval:n{#1}}{#2} } \cs_new_protected:Npn \prg_stepwise_variable_incr:nnnNn #1#2#3#4#5 { \int_compare:nNnF {#1}>{#3} { \cs_set_nopar:Npn #4{#1} #5 \exp_args:Nf \prg_stepwise_variable_incr:nnnNn {\int_eval:n{#1 + #2}}{#2}{#3}#4{#5} } } \cs_new_protected:Npn \prg_stepwise_variable_decr:nnnNn #1#2#3#4#5 { \int_compare:nNnF {#1}<{#3} { \cs_set_nopar:Npn #4{#1} #5 \exp_args:Nf \prg_stepwise_variable_decr:nnnNn {\int_eval:n{#1 + #2}}{#2}{#3}#4{#5} } } \cs_new_protected_nopar:Npn \bool_new:N #1 { \cs_new_eq:NN #1 \c_false_bool } \cs_new_protected_nopar:Npn \bool_new:c #1 { \cs_new_eq:cN {#1} \c_false_bool } \cs_new_protected_nopar:Npn \bool_set_true:N #1 { \cs_set_eq:NN #1 \c_true_bool } \cs_new_protected_nopar:Npn \bool_set_true:c #1 { \cs_set_eq:cN {#1} \c_true_bool } \cs_new_protected_nopar:Npn \bool_set_false:N #1 { \cs_set_eq:NN #1 \c_false_bool } \cs_new_protected_nopar:Npn \bool_set_false:c #1 { \cs_set_eq:cN {#1} \c_false_bool } \cs_new_protected_nopar:Npn \bool_gset_true:N #1 { \cs_gset_eq:NN #1 \c_true_bool } \cs_new_protected_nopar:Npn \bool_gset_true:c #1 { \cs_gset_eq:cN {#1} \c_true_bool } \cs_new_protected_nopar:Npn \bool_gset_false:N #1 { \cs_gset_eq:NN #1 \c_false_bool } \cs_new_protected_nopar:Npn \bool_gset_false:c #1 { \cs_gset_eq:cN {#1} \c_false_bool } \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 \bool_new:N \l_tmpa_bool \bool_new:N \g_tmpa_bool \prg_set_conditional:Npnn \bool_if:N #1 {p,TF,T,F}{ \if_bool:N #1 \prg_return_true: \else: \prg_return_false: \fi: } \cs_generate_variant:Nn \bool_if_p:N {c} \cs_generate_variant:Nn \bool_if:NTF {c} \cs_generate_variant:Nn \bool_if:NT {c} \cs_generate_variant:Nn \bool_if:NF {c} \cs_new:Npn \bool_while_do:Nn #1 #2 { \bool_if:NT #1 {#2 \bool_while_do:Nn #1 {#2}} } \cs_generate_variant:Nn \bool_while_do:Nn {c} \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_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_generate_variant:Nn \bool_do_while:Nn {c} \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_until:Nn {c} \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 \tex_number:D \bool_get_not_next:N } \cs_new:Npn \bool_not_Not:w { \exp_after:wN \tex_number:D \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 \tex_number:D \bool_get_next:N } \cs_new:cpn {bool_not_(:w}#1{ \exp_after:wN \bool_not_cleanup:N \tex_number:D \bool_get_next:N } \cs_new:cpn {bool_p:w}{\exp_after:wN \bool_cleanup:N \tex_number:D } \cs_new:cpn {bool_not_p:w}{\exp_after:wN \bool_not_cleanup:N \tex_number:D } \cs_new_nopar:Npn \bool_cleanup:N #1{ \exp_after:wN \bool_choose:NN \exp_after:wN #1 \int_to_roman:w-`\q } \cs_new_nopar:Npn \bool_not_cleanup:N #1{ \exp_after:wN \bool_not_choose:NN \exp_after:wN #1 \int_to_roman:w-`\q } \cs_new_nopar:Npn \bool_choose:NN #1#2{ \use:c{bool_#2_#1:w} } \cs_new_nopar: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:cpn{bool_&_0:w}&{\bool_eval_skip_to_end:Nw \c_false_bool} \cs_new:cpn{bool_|_1:w}|{\bool_eval_skip_to_end:Nw \c_true_bool} \cs_new:cpn{bool_not_&_1:w}&{\bool_eval_skip_to_end:Nw \c_false_bool} \cs_new: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_auxii:Nw #1 #5 } } \cs_new:Npn \bool_eval_skip_to_end_auxii:Nw #1#2(#3){ \bool_eval_skip_to_end:Nw #1#3 ) } \cs_new:Npn \bool_set:Nn #1#2 {\tex_chardef:D #1 = \bool_if_p:n {#2}} \cs_new: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} \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} } \prg_set_conditional:Npnn \bool_if:n #1 {TF,T,F}{ \if_predicate:w \bool_if_p:n{#1} \prg_return_true: \else: \prg_return_false: \fi: } \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_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_new:Npn \prg_case_int:nnn #1 #2 { \exp_args:Nf \prg_case_int_aux:nnn { \int_eval:n{#1}} #2 \q_recursion_tail ? \q_recursion_stop } \cs_new:Npn \prg_case_int_aux:nnn #1#2#3{ \quark_if_recursion_tail_stop_do:nn{#2}{\use:n} \int_compare:nNnTF{#1}={#2} { \prg_end_case:nw {#3} } { \prg_case_int_aux:nnn {#1}} } \cs_new:Npn \prg_case_dim:nnn #1 #2 { \exp_args:No \prg_case_dim_aux:nnn {\dim_eval:n{#1}} #2 \q_recursion_tail ? \q_recursion_stop } \cs_new:Npn \prg_case_dim_aux:nnn #1#2#3{ \quark_if_recursion_tail_stop_do:nn{#2}{\use:n} \dim_compare:nNnTF{#1}={#2} { \prg_end_case:nw {#3} } { \prg_case_dim_aux:nnn {#1}} } \cs_new:Npn \prg_case_str:nnn #1 #2 { \prg_case_str_aux:nnn {#1} #2 \q_recursion_tail ? \q_recursion_stop } \cs_new:Npn \prg_case_str_aux:nnn #1#2#3{ \quark_if_recursion_tail_stop_do:nn{#2}{\use:n} \str_if_eq:xxTF{#1}{#2} { \prg_end_case:nw {#3} } { \prg_case_str_aux:nnn {#1}} } \cs_new:Npn \prg_case_tl:Nnn #1 #2 { \prg_case_tl_aux:NNn #1 #2 \q_recursion_tail ? \q_recursion_stop } \cs_new:Npn \prg_case_tl_aux:NNn #1#2#3{ \quark_if_recursion_tail_stop_do:Nn #2{\use:n} \tl_if_eq:NNTF #1 #2 { \prg_end_case:nw {#3} } { \prg_case_tl_aux:NNn #1} } \cs_new:Npn \prg_end_case:nw #1#2\q_recursion_stop#3{#1} \cs_new_protected_nopar: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} \group_begin: \tex_lccode:D `\& = `\g \tex_relax:D \tex_catcode:D `\& = \c_twelve \tex_relax:D \tl_to_lowercase:n { \group_end: \cs_new_nopar:Npn \prg_variable_get_scope:N #1 { \exp_last_unbraced:Nf \prg_variable_get_scope_aux:w { \cs_to_str:N #1 \exp_stop_f: \q_stop } } \cs_new_nopar:Npn \prg_variable_get_scope_aux:w #1#2 \q_stop { \token_if_eq_meaning:NNT & #1 {g} } } \group_begin: \tex_lccode:D `\& = `\_ \tex_relax:D \tex_catcode:D `\& = \c_twelve \tex_relax:D \tl_to_lowercase:n { \group_end: \cs_new_nopar:Npn \prg_variable_get_type:N #1 { \exp_after:wN \p;rg_variable_get_type_aux:w \token_to_str:N #1 & a \q_stop } \cs_new_nopar: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 } } } \cs_new_protected:Npn \prg_new_map_functions:Nn #1#2 { \cs_if_free:cTF { #2 _map_function:NN } { \prg_set_map_functions:Nn #1 {#2} } { \msg_kernel_error:nnx { code } { csname-already-defined } { \token_to_str:c { #2 _map_function:NN } } } } \cs_new_protected:Npn \prg_set_map_functions:Nn #1#2 { \cs_gset_nopar:cpx { #2 _map_function:NN } ##1##2 { \exp_not:N \tl_if_empty:NF ##1 { \exp_not:N \exp_after:wN \exp_not:c { #2 _map_function_aux:Nw } \exp_not:N \exp_after:wN ##2 ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop } } } \cs_gset:cpx { #2 _map_function:nN } ##1##2 { \exp_not:N \tl_if_blank:nF {##1} { \exp_not:c { #2 _map_function_aux:Nw } ##2 ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop } } } \cs_gset:cpx { #2 _map_function_aux:Nw } ##1##2 #1 { \exp_not:N \quark_if_recursion_tail_stop:n {##2} ##1 {##2} \exp_not:c { #2 _map_function_aux:Nw } ##1 } \cs_if_free:cT { g_ #2 _map_inline_int } { \int_new:c { g_ #2 _map_inline_int } } \cs_gset_protected_nopar:cpx { #2 _map_inline:Nn } ##1##2 { \exp_not:N \tl_if_empty:NF ##1 { \exp_not:N \int_gincr:N \exp_not:c { g_ #2 _map_inline_int } \cs_gset:cpn { #2 _map_inline_ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int } :n } ####1 {##2} \exp_not:N \exp_last_unbraced:NcV \exp_not:c { #2 _map_function_aux:Nw } { #2 _map_inline_ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int } :n } ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop } \exp_not:N \int_gdecr:N \exp_not:c { g_ #2 _map_inline_int } } } \cs_gset_protected:cpx { #2 _map_inline:nn } ##1##2 { \exp_not:N \tl_if_empty:nF {##1} { \exp_not:N \int_gincr:N \exp_not:c { g_ #2 _map_inline_int } \cs_gset:cpn { #2 _map_inline_ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int } :n } ####1 {##2} \exp_not:N \exp_args:Nc \exp_not:c { #2 _map_function_aux:Nw } { #2 _map_inline_ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int } :n } ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop } \exp_not:N \int_gdecr:N \exp_not:c { g_ #2 _map_inline_int } } } \cs_gset_eq:cN { #2 _map_break: } \use_none_delimit_by_q_recursion_stop:w } %% %% %% End of file `l3prg.sty'.