%% %% 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-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: l3prg.dtx 4459 2013-02-13 09:21:15Z will $ {L3 Control structures} %% \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \__expl_package_check: \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_show_variable:n { > ~ true } } { \__msg_show_variable:n { > ~ false } } } \cs_generate_variant:Nn \bool_show:N { c } \bool_new:N \l_tmpa_bool \bool_new:N \l_tmpb_bool \bool_new:N \g_tmpa_bool \bool_new:N \g_tmpb_bool \prg_new_eq_conditional:NNn \bool_if_exist:N \cs_if_exist:N { TF , T , F , p } \prg_new_eq_conditional:NNn \bool_if_exist:c \cs_if_exist:c { TF , T , F , p } \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_if_left_parentheses:wwwn \q_nil #1 \q_mark { } ( \q_mark { \__bool_if_right_parentheses:wwwn \q_nil } ) \q_mark { \__bool_if_or:wwwn \q_nil } || \q_mark \__bool_if_parse:NNNww \q_stop } \cs_new:Npn \__bool_if_left_parentheses:wwwn #1 \q_nil #2 ( #3 \q_mark #4 { #4 \__bool_if_left_parentheses:wwwn #1 #2 (( \q_nil #3 \q_mark {#4} } \cs_new:Npn \__bool_if_right_parentheses:wwwn #1 \q_nil #2 ) #3 \q_mark #4 { #4 \__bool_if_right_parentheses:wwwn #1 #2 )) \q_nil #3 \q_mark {#4} } \cs_new:Npn \__bool_if_or:wwwn #1 \q_nil #2 || #3 \q_mark #4 { #4 \__bool_if_or:wwwn #1 #2 )||( \q_nil #3 \q_mark {#4} } \cs_new:Npn \__bool_if_parse:NNNww #1#2#3#4 \q_mark #5 \q_stop { \__bool_get_next:NN \use_i:nn (( #4 )) S } \cs_new:Npn \__bool_get_next:NN #1#2 { \use:c { __bool_ \if_meaning:w !#2 ! \else: \if_meaning:w (#2 ( \else: p \fi: \fi: :Nw } #1 #2 } \cs_new:cpn { __bool_!:Nw } #1#2 { \exp_after:wN \__bool_get_next:NN #1 \use_ii:nn \use_i:nn } \cs_new:cpn { __bool_(:Nw } #1#2 { \exp_after:wN \__bool_choose:NNN \exp_after:wN #1 \__int_value:w \__bool_get_next:NN \use_i:nn } \cs_new:cpn { __bool_p:Nw } #1 { \exp_after:wN \__bool_choose:NNN \exp_after:wN #1 \__int_value:w } \cs_new:Npn \__bool_choose:NNN #1#2#3 { \use:c { __bool_ #3 _ #1 #2 { \if_meaning:w 0 #2 1 \else: 0 \fi: } :w } } \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_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_&_1:w } & { \__bool_get_next:NN \use_i:nn } \cs_new_nopar:cpn { __bool_|_0:w } | { \__bool_get_next:NN \use_i:nn } \cs_new_nopar:cpn { __bool_&_0:w } & { \__bool_eval_skip_to_end_auxi:Nw \c_false_bool } \cs_new_nopar:cpn { __bool_|_1:w } | { \__bool_eval_skip_to_end_auxi:Nw \c_true_bool } %% ( \cs_new:Npn \__bool_eval_skip_to_end_auxi:Nw #1#2 ) { \__bool_eval_skip_to_end_auxii:Nw #1#2 ( % ) \q_no_value \q_stop {#2} } \cs_new:Npn \__bool_eval_skip_to_end_auxii:Nw #1#2 ( #3#4 \q_stop #5 % ) { \quark_if_no_value:NTF #3 {#1} { \__bool_eval_skip_to_end_auxiii:Nw #1 #5 } } \cs_new:Npn \__bool_eval_skip_to_end_auxiii:Nw #1#2 ( #3 ) { % ( \__bool_eval_skip_to_end_auxi: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_replicate:nn #1 { \__int_to_roman:w \exp_after:wN \__prg_replicate_first:N \__int_value:w \__int_eval:w #1 \__int_eval_end: \cs_end: } \cs_new:Npn \__prg_replicate:N #1 { \cs:w __prg_replicate_#1 :n \__prg_replicate:N } \cs_new:Npn \__prg_replicate_first:N #1 { \cs:w __prg_replicate_first_ #1 :n \__prg_replicate: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_kernel_expandable_error:nn { kernel } { negative-replication } } \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 } \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:w \cs_to_str:N #1 \exp_stop_f: \q_stop } \cs_new:Npn \__prg_variable_get_scope: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:w \token_to_str:N #1 * a \q_stop } \cs_new:Npn \__prg_variable_get_type:w #1 * #2#3 \q_stop { \token_if_eq_meaning:NNTF a #2 {#1} { \__prg_variable_get_type:w #2#3 \q_stop } } } \int_new:N \g__prg_map_int %% %% %% End of file `l3prg.sty'.