summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/expl3/l3prg.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/expl3/l3prg.sty')
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3prg.sty394
1 files changed, 394 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/expl3/l3prg.sty b/Master/texmf-dist/tex/latex/expl3/l3prg.sty
new file mode 100644
index 00000000000..fad727278da
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/expl3/l3prg.sty
@@ -0,0 +1,394 @@
+%%
+%% 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-2006 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: l3prg.dtx 574 2006-08-21 23:30:10Z morten $
+ {L3 Experimental control structures}
+\RequirePackage{l3quark}
+\RequirePackage{l3toks}
+\RequirePackage{l3int}
+\def_new:Npn \mode_vertical_p: {
+ \if_mode_vertical: \c_true \else: \c_false\fi:}
+\def_test_function_new:npn{mode_vertical:}{\if_mode_vertical:}
+\def_new:Npn \mode_horizontal_p: {
+ \if_mode_horizontal: \c_true \else: \c_false\fi:}
+\def_test_function_new:npn{mode_horizontal:}{\if_mode_horizontal:}
+\def_new:Npn \mode_inner_p: {
+ \if_mode_inner: \c_true \else: \c_false\fi:}
+\def_test_function_new:npn{mode_inner:}{\if_mode_inner:}
+\def_test_function_new:npn{mode_math:} {
+ \scan_align_safe_stop: \if_mode_math: }
+\def_new:Npn \group_align_safe_begin: {\if_false:{\fi:\if_num:w0=`}\fi:}
+\def_new:Npn \group_align_safe_end: {\if_num:w0=`{\fi:\if_false:}\fi:}
+\def_new:Npn \scan_align_safe_stop: {
+ \num_compare:nNnT \etex_currentgrouptype:D = \c_six
+ {
+ \num_compare:nNnF \etex_lastnodetype:D = \c_zero
+ {
+ \num_compare:nNnF \etex_lastnodetype:D = \c_seven
+ \scan_stop:
+ }
+ }
+}
+\def_new:Npn \prg_replicate:nn #1{
+ \cs:w use_noop:
+ \exp_after:NN\prg_replicate_first_aux:N
+ \int_use:N \int_eval:n{#1} \cs_end:
+ \cs_end:
+}
+\def_new:Npn \prg_replicate_aux:N#1{
+ \cs:w prg_replicate_#1:n\prg_replicate_aux:N
+}
+\def_new:Npn \prg_replicate_first_aux:N#1{
+ \cs:w prg_replicate_first_#1:n\prg_replicate_aux:N
+}
+\def_new:Npn \prg_replicate_ :n #1{}% no, this is not a typo!
+\def_long_new:cpn {prg_replicate_0:n}#1{\cs_end:{#1#1#1#1#1#1#1#1#1#1}}
+\def_long_new:cpn {prg_replicate_1:n}#1{\cs_end:{#1#1#1#1#1#1#1#1#1#1}#1}
+\def_long_new:cpn {prg_replicate_2:n}#1{\cs_end:{#1#1#1#1#1#1#1#1#1#1}#1#1}
+\def_long_new:cpn {prg_replicate_3:n}#1{
+ \cs_end:{#1#1#1#1#1#1#1#1#1#1}#1#1#1}
+\def_long_new:cpn {prg_replicate_4:n}#1{
+ \cs_end:{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1}
+\def_long_new:cpn {prg_replicate_5:n}#1{
+ \cs_end:{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1}
+\def_long_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}
+\def_long_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}
+\def_long_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}
+\def_long_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}
+\def_long_new:cpn {prg_replicate_first_0:n}#1{\cs_end: }
+\def_long_new:cpn {prg_replicate_first_1:n}#1{\cs_end: #1}
+\def_long_new:cpn {prg_replicate_first_2:n}#1{\cs_end: #1#1}
+\def_long_new:cpn {prg_replicate_first_3:n}#1{\cs_end: #1#1#1}
+\def_long_new:cpn {prg_replicate_first_4:n}#1{\cs_end: #1#1#1#1}
+\def_long_new:cpn {prg_replicate_first_5:n}#1{\cs_end: #1#1#1#1#1}
+\def_long_new:cpn {prg_replicate_first_6:n}#1{\cs_end: #1#1#1#1#1#1}
+\def_long_new:cpn {prg_replicate_first_7:n}#1{\cs_end: #1#1#1#1#1#1#1}
+\def_long_new:cpn {prg_replicate_first_8:n}#1{\cs_end: #1#1#1#1#1#1#1#1}
+\def_long_new:cpn {prg_replicate_first_9:n}#1{\cs_end: #1#1#1#1#1#1#1#1#1}
+\def_long_new:NNn \prg_stepwise_function:nnnN 2{
+ \num_compare:nNnTF{#2}<\c_zero
+ {\exp_args:No\prg_stepwise_function_decr:nnnN }
+ {\exp_args:No\prg_stepwise_function_incr:nnnN }
+ {\int_use:N\int_eval:n{#1}}{#2}
+}
+\def_long_new:NNn \prg_stepwise_function_incr:nnnN 4{
+ \num_compare:nNnF {#1}>{#3}
+ {
+ #4{#1}
+ \exp_args:No \prg_stepwise_function_incr:nnnN
+ {\int_use:N\int_eval:n{#1 + #2}}
+ {#2}{#3}{#4}
+ }
+}
+\def_long_new:NNn \prg_stepwise_function_decr:nnnN 4{
+ \num_compare:nNnF {#1}<{#3}
+ {
+ #4{#1}
+ \exp_args:No \prg_stepwise_function_decr:nnnN
+ {\int_use:N\int_eval:n{#1 + #2}}
+ {#2}{#3}{#4}
+ }
+}
+\int_new:N\l_prg_inline_level_int
+\def_long_new:NNn\prg_stepwise_inline:nnnn 4{
+ \int_incr:N \l_prg_inline_level_int
+ \def:cpn{prg_stepwise_inline_\int_use:N\l_prg_inline_level_int :n}##1{#4}
+ \num_compare:nNnTF {#2}<\c_zero
+ {\exp_args:Nco \prg_stepwise_inline_decr:Nnnn }
+ {\exp_args:Nco \prg_stepwise_inline_incr:Nnnn }
+ {prg_stepwise_inline_\int_use:N\l_prg_inline_level_int :n}
+ {\int_use:N\int_eval:n{#1}} {#2} {#3}
+ \int_decr:N \l_prg_inline_level_int
+}
+\def_long_new:NNn \prg_stepwise_inline_incr:Nnnn 4{
+ \num_compare:nNnF {#2}>{#4}
+ {
+ #1{#2}
+ \exp_args:NNo \prg_stepwise_inline_incr:Nnnn #1
+ {\int_use:N\int_eval:n{#2 + #3}} {#3}{#4}
+ }
+}
+\def_long_new:NNn \prg_stepwise_inline_decr:Nnnn 4{
+ \num_compare:nNnF {#2}<{#4}
+ {
+ #1{#2}
+ \exp_args:NNo \prg_stepwise_inline_decr:Nnnn #1
+ {\int_use:N\int_eval:n{#2 + #3}} {#3}{#4}
+ }
+}
+\def_long_new:NNn \prg_stepwise_variable:nnnNn 2 {
+ \num_compare:nNnTF {#2}<\c_zero
+ {\exp_args:No\prg_stepwise_variable_decr:nnnNn}
+ {\exp_args:No\prg_stepwise_variable_incr:nnnNn}
+ {\int_use:N\int_eval:n{#1}}{#2}
+}
+\def_long_new:NNn \prg_stepwise_variable_incr:nnnNn 5 {
+ \num_compare:nNnF {#1}>{#3}
+ {
+ \def:Npn #4{#1} #5
+ \exp_args:No \prg_stepwise_variable_incr:nnnNn
+ {\int_use:N\int_eval:n{#1 + #2}}{#2}{#3}#4{#5}
+ }
+}
+\def_long_new:NNn \prg_stepwise_variable_decr:nnnNn 5 {
+ \num_compare:nNnF {#1}<{#3}
+ {
+ \def:Npn #4{#1} #5
+ \exp_args:No \prg_stepwise_variable_decr:nnnNn
+ {\int_use:N\int_eval:n{#1 + #2}}{#2}{#3}#4{#5}
+ }
+}
+\def_new:Npn \bool_new:N #1 { \let_new:NN #1 \c_false }
+\def_new:Npn \bool_new:c #1 { \let_new:cN #1 \c_false }
+\def_new:Npn \bool_set_true:N #1 { \let:NN #1 \c_true }
+\def_new:Npn \bool_set_true:c #1 { \let:cN #1 \c_true }
+\def_new:Npn \bool_set_false:N #1 { \let:NN #1 \c_false }
+\def_new:Npn \bool_set_false:c #1 { \let:cN #1 \c_false }
+\def_new:Npn \bool_gset_true:N #1 { \glet:NN #1 \c_true }
+\def_new:Npn \bool_gset_true:c #1 { \glet:cN #1 \c_true }
+\def_new:Npn \bool_gset_false:N #1 { \glet:NN #1 \c_false }
+\def_new:Npn \bool_gset_false:c #1 { \glet:cN #1 \c_false }
+\let_new:NN \bool_set_eq:NN \let:NN
+\let_new:NN \bool_set_eq:Nc \let:Nc
+\let_new:NN \bool_set_eq:cN \let:cN
+\let_new:NN \bool_set_eq:cc \let:cc
+\let_new:NN \bool_gset_eq:NN \glet:NN
+\let_new:NN \bool_gset_eq:Nc \glet:Nc
+\let_new:NN \bool_gset_eq:cN \glet:cN
+\let_new:NN \bool_gset_eq:cc \glet:cc
+\bool_new:N \l_tmpa_bool
+\bool_new:N \g_tmpa_bool
+\def_test_function_new:npn{bool_if:N}#1{\if:w #1}
+\def_new:Npn \bool_if:cTF{\exp_args:Nc\bool_if:NTF}
+\def_new:Npn \bool_if:cT{\exp_args:Nc\bool_if:NT}
+\def_new:Npn \bool_if:cF{\exp_args:Nc\bool_if:NF}
+\def_new:Npn \bool_if_p:N #1 { #1 }
+\let_new:NN \bool_if_p:c \cs_use:c
+\def_long_new:Npn \bool_whiledo:NT #1 #2 {
+ \bool_if:NT #1 {#2 \bool_whiledo:NT #1 {#2}}
+}
+\def_new:Npn \bool_whiledo:cT{\exp_args:Nc\bool_whiledo:NT}
+\def_long_new:Npn \bool_whiledo:NF #1 #2 {
+ \bool_if:NF #1 {#2 \bool_whiledo:NF #1 {#2}}
+}
+\def_new:Npn \bool_whiledo:cF{\exp_args:Nc\bool_whiledo:NF}
+\def_long_new:Npn \bool_dowhile:NT #1 #2 {
+ #2 \bool_if:NT #1 {\bool_dowhile:NT #1 {#2}}
+}
+\def_new:Npn \bool_dowhile:cT{\exp_args:Nc\bool_dowhile:NT}
+\def_long_new:Npn \bool_dowhile:NF #1 #2 {
+ #2 \bool_if:NF #1 {\bool_dowhile:NF #1 {#2}}
+}
+\def_new:Npn \bool_dowhiledo:cF{\exp_args:Nc\bool_dowhile:cF}
+\def_new:Npn \bool_double_if:NNnnnn#1#2{
+ \if_case:w \num_eval:w #1\scan_stop:
+ \if_case:w \num_eval:w #2\scan_stop:
+ \exp_after:NN\exp_after:NN\exp_after:NN \use_arg_i:nnnn
+ \else:
+ \exp_after:NN\exp_after:NN\exp_after:NN \use_arg_ii:nnnn
+ \fi:
+ \else:
+ \if_case:w \num_eval:w #2\scan_stop:
+ \exp_after:NN\exp_after:NN\exp_after:NN \use_arg_iii:nnnn
+ \else:
+ \exp_after:NN\exp_after:NN\exp_after:NN \use_arg_iv:nnnn
+ \fi:
+ \fi:
+}
+\def_new:Npn \bool_double_if:cNnnnn{\exp_args:Nc\bool_double_if:NNnnnn}
+\def_new:Npn \bool_double_if:Ncnnnn{\exp_args:NNc\bool_double_if:NNnnnn}
+\def_new:Npn \bool_double_if:ccnnnn{\exp_args:Ncc\bool_double_if:NNnnnn}
+\def_long_new:Npn \prg_whiledo:nT #1#2{
+ #1 {#2 \prg_whiledo:nT {#1}{#2}}
+}
+\def_long_new:Npn \prg_whiledo:nF #1#2{
+ #1 {#2 \prg_whiledo:nF {#1}{#2}}
+}
+\def_long_new:Npn \prg_dowhile:nT #1#2{
+ #2 #1 {\prg_dowhile:nT {#1}{#2}}
+}
+\def_long_new:Npn \prg_dowhile:nF #1#2{
+ #2 #1 {\prg_dowhile:nF {#1}{#2}}
+}
+\let_new:NN \prg_if_predicate:nTF \bool_if:NTF
+\let_new:NN \prg_if_predicate:nT \bool_if:NT
+\let_new:NN \prg_if_predicate:nF \bool_if:NF
+\def_new:Npn \prg_if_predicate_or_p:nn #1#2{
+ \if_num:w #1#2<\c_hundred_one
+ \c_true
+ \else:
+ \c_false
+ \fi:
+}
+\def_new:Npn \prg_if_predicate_and_p:nn #1#2{
+ \if_case:w #1#2 ~
+ \c_true
+ \else:
+ \c_false
+ \fi:
+}
+\def_new:Npn \prg_if_predicate_not_p:n #1{
+ \if_case:w #1 ~
+ \c_false
+ \or:
+ \c_true
+ \fi:
+}
+\def_long_new:Npn \prg_if_predicate_ands_p:n #1{
+ \exp_after:NN \prg_if_predicate_andor_aux:NNN \exp_after:NN \c_true
+ \int_to_roman:w -`0 #1 \scan_stop: \scan_stop:
+}
+\def_long_new:Npn \prg_if_predicate_ors_p:n #1{
+ \exp_after:NN \prg_if_predicate_andor_aux:NNN \exp_after:NN \c_false
+ \int_to_roman:w -`0 #1 \scan_stop: \scan_stop:
+}
+\def_new:Npn \prg_if_predicate_andor_aux:NNN #1#2#3{
+ \token_if_eq_meaning:NNTF \scan_stop: #2
+ { #1 }
+ {
+ \int_compare:nNnTF #3 = #1
+ { \exp_after:NN \prg_if_predicate_andor_aux:NNN }
+ { \exp_after:NN \prg_if_predicate_andor_break:NNN }
+ \exp_after:NN #1 \int_to_roman:w -`0
+ }
+}
+\def_new:Npn \prg_if_predicate_andor_break:NNN #1#2#3{
+ \token_if_eq_meaning:NNTF \scan_stop: #2
+ { \if:w #1\c_false\else:\c_true\fi: }
+ {
+ \exp_after:NN \prg_if_predicate_andor_break:NNN \exp_after:NN #1
+ \int_to_roman:w -`0
+ }
+}
+\def_new:NNn \prg_define_quicksort:nnn 3 {
+ \def_long:cNx{#1_quicksort:n}1{
+ \exp_not:c{#1_quicksort_start_partition:w} ##1
+ \exp_not:n{#2\q_nil#3\q_stop}
+ }
+ \def_long:cNx{#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
+ }
+ \def_long: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}{}{}
+ }
+ \def_long:cNx {#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}{}{}
+ }
+ \def_long: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}
+ }
+ \def_long:cNx {#1_quicksort_do_partition_i_braced:nnnn} 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}
+ }
+ \def_long: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}
+ }
+ \def_long:cNx {#1_quicksort_do_partition_ii_braced:nnnn} 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}
+ }
+ \def_long:cNx {#1_quicksort_partition_less_i:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_i:nnnw}{##1}{##2}{{##4}##3}}
+ \def_long:cNx {#1_quicksort_partition_less_ii:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_ii:nnnw}{##1}{##2}{##3{##4}}}
+ \def_long:cNx {#1_quicksort_partition_greater_i:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_i:nnnw}{##1}{{##4}##2}{##3}}
+ \def_long:cNx {#1_quicksort_partition_greater_ii:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_ii:nnnw}{##1}{##2{##4}}{##3}}
+ \def_long:cNx {#1_quicksort_partition_less_i_braced:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_i_braced:nnnn}{##1}{##2}{{##4}##3}}
+ \def_long:cNx {#1_quicksort_partition_less_ii_braced:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_ii_braced:nnnn}{##1}{##2}{##3{##4}}}
+ \def_long:cNx {#1_quicksort_partition_greater_i_braced:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_i_braced:nnnn}{##1}{{##4}##2}{##3}}
+ \def_long:cNx {#1_quicksort_partition_greater_ii_braced:nnnn} 4{
+ \exp_not:c{#1_quicksort_do_partition_ii_braced:nnnn}{##1}{##2{##4}}{##3}}
+ \def_long: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}{}{}
+\let:NN \prg_quicksort_function:n \ERROR
+\let:NN \prg_quicksort_compare:nnTF \ERROR
+%%
+%%
+%% End of file `l3prg.sty'.