summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/functional/functional.sty629
1 files changed, 450 insertions, 179 deletions
diff --git a/Master/texmf-dist/tex/latex/functional/functional.sty b/Master/texmf-dist/tex/latex/functional/functional.sty
index 59e578368b2..a7d97ebfb17 100644
--- a/Master/texmf-dist/tex/latex/functional/functional.sty
+++ b/Master/texmf-dist/tex/latex/functional/functional.sty
@@ -14,7 +14,7 @@
\NeedsTeXFormat{LaTeX2e}[2018-04-01]
\RequirePackage{expl3}
-\ProvidesExplPackage{functional}{2022-04-15}{2022D}
+\ProvidesExplPackage{functional}{2022-04-29}{2022E}
{^^JLaTeX2 functional interfaces for LaTeX3 programming layer}
\cs_generate_variant:Nn \iow_log:n { V }
@@ -24,6 +24,19 @@
\prg_generate_conditional_variant:Nnn \str_if_eq:nn { Ve } { TF }
+\cs_new_protected:Npn \__fun_ignore_spaces_on:
+ {
+ \ExplSyntaxOn
+ \char_set_catcode_math_subscript:N \_
+ \char_set_catcode_other:N \:
+ }
+\cs_set_eq:NN \IgnoreSpacesOn \__fun_ignore_spaces_on:
+\cs_set_eq:NN \IgnoreSpacesOff \ExplSyntaxOff
+
+%%% --------------------------------------------------------
+%%> \subsection{Creating New Functions and Conditionals}
+%%% --------------------------------------------------------
+
\tl_new:N \gResultTl
\int_new:N \l__fun_arg_count_int
\tl_new:N \l__fun_parameters_defined_tl
@@ -333,6 +346,8 @@
\cs_generate_variant:Nn \__fun_new_with_arg_ix:Nnn { NnV }
\tl_new:N \l__fun_argtype_tl
+\tl_const:Nn \c__fun_argtype_e_tl { e }
+\tl_const:Nn \c__fun_argtype_E_tl { E }
\tl_const:Nn \c__fun_argtype_m_tl { m }
\tl_const:Nn \c__fun_argtype_M_tl { M }
\tl_const:Nn \c__fun_argtype_n_tl { n }
@@ -350,6 +365,14 @@
\__fun_one_argument_get:eN { \__fun_argtype_index_use: } \l__fun_argument_tl
\tl_case:Nn \l__fun_argtype_tl
{
+ \c__fun_argtype_e_tl
+ {
+ \__fun_evaluate_all_and_put_argument:N \l__fun_argument_tl
+ }
+ \c__fun_argtype_E_tl
+ {
+ \__fun_evaluate_all_and_put_argument:N \l__fun_argument_tl
+ }
\c__fun_argtype_m_tl
{
\__fun_evaluate_and_put_argument:N \l__fun_argument_tl
@@ -372,6 +395,12 @@
\__fun_arguments_called:c { __fun_defined_ \cs_to_str:N #1 : w }
}
+\cs_new_protected:Npn \__fun_evaluate_all_and_put_argument:N #1
+ {
+ \__fun_eval_all:V #1
+ \__fun_arguments_gput:e { { \exp_not:V \gResultTl } }
+ }
+
\cs_new_protected:Npn \__fun_evaluate_and_put_argument:N #1
{
\cs_if_exist:cTF
@@ -466,17 +495,24 @@
}
\cs_generate_variant:Nn \__fun_arguments_gput:n { e }
+\cs_if_exist:NF \Do { \PrgNewFunction \Do { n } { #1 } }
+\PrgNewFunction \PrgDo { n } { #1 }
+
\cs_set_eq:NN \Break \prg_break:
\cs_set_eq:NN \PrgBreak \prg_break:
\cs_set_eq:NN \BreakDo \prg_break:n
\cs_set_eq:NN \PrgBreakDo \prg_break:n
+%%% --------------------------------------------------------
+%%> \subsection{Return Values and Return Processors}
+%%% --------------------------------------------------------
+
\cs_new_protected:Npn \__fun_put_result:n #1
{
\tl_gput_right:Nn \gResultTl { #1 }
}
-\cs_generate_variant:Nn \__fun_put_result:n { e, V }
+\cs_generate_variant:Nn \__fun_put_result:n { V, e, f, o }
\PrgNewFunction \Return { m }
{
@@ -488,12 +524,94 @@
\__fun_put_result:n { #1 }
}
+\int_new:N \l__fun_return_level_int
+
+%% By default, the result is returned only if the function is not
+%% nested in another function, but this behavior can be customized
\cs_new_protected:Npn \__fun_return_result:
{
- \int_compare:nNnT { \g__fun_nesting_level_int } = { 0 }
- { \tl_use:N \gResultTl }
+ \int_compare:nNnT { \g__fun_nesting_level_int } = { \l__fun_return_level_int }
+ { \__fun_use_result: }
+ }
+
+\cs_new_protected:Npn \__fun_use_result_default:
+ {
+ \tl_use:N \gResultTl
+ }
+
+%% Set default return processor
+\cs_new_protected:Npn \__fun_set_return_processor_default:
+ {
+ \int_set:Nn \l__fun_return_level_int {0}
+ \cs_set_eq:NN \__fun_use_result: \__fun_use_result_default:
+ }
+
+\__fun_set_return_processor_default:
+
+%% Set current nesting level and return processor
+\cs_new_protected:Npn \__fun_set_return_processor:n #1
+ {
+ \int_set_eq:NN \l__fun_return_level_int \g__fun_nesting_level_int
+ \cs_set_protected:Npn \__fun_use_result: { #1 }
+ }
+
+%% #1: return processor; #2: code to run
+%% We do it inside groups for nesting processors to make correct results
+\cs_new_protected:Npn \fun_run_return_processor:nn #1 #2
+ {
+ \group_begin:
+ \__fun_set_return_processor:n {#1}
+ #2
+ \group_end:
+ }
+
+%%% --------------------------------------------------------
+%%> \subsection{Evaluating Functions inside Arguments}
+%%% --------------------------------------------------------
+
+\tl_new:N \l__fun_eval_result_tl
+
+%% Evaluate all functions in #1 and replace them with their return values
+\cs_new_protected:Npn \__fun_eval_all:n #1
+ {
+ \fun_run_return_processor:nn
+ { \exp_last_unbraced:NV \__fun_eval_all_aux:n \gResultTl }
+ {
+ \tl_clear:N \l__fun_eval_result_tl
+ \__fun_eval_all_aux:n #1 \q_stop
+ \tl_gset_eq:NN \gResultTl \l__fun_eval_result_tl
+ }
+ }
+\cs_generate_variant:Nn \__fun_eval_all:n { V }
+
+\cs_new_protected:Npn \__fun_eval_all_aux:n #1
+ {
+ \tl_if_single_token:nTF {#1}
+ {
+ \token_if_eq_meaning:NNF #1 \q_stop
+ {
+ \bool_lazy_and:nnTF
+ { \token_if_cs_p:N #1 }
+ { \cs_if_exist_p:c { __fun_defined_ \cs_to_str:N #1 : w } }
+ { #1 }
+ {
+ \tl_put_right:Nn \l__fun_eval_result_tl {#1}
+ \__fun_eval_all_aux:n
+ }
+ }
+ }
+ {
+ %% The braces enclosing a single token (such as {x}) are removed
+ %% but I guess there is no harm inside \int_eval:n or \fp_eval:n
+ \tl_put_right:Nn \l__fun_eval_result_tl { {#1} }
+ \__fun_eval_all_aux:n
+ }
}
+%%% --------------------------------------------------------
+%%> \subsection{Checking for Local or Global Variables}
+%%% --------------------------------------------------------
+
\str_new:N \l__fun_variable_name_str
\str_new:N \l__fun_variable_name_a_str
\str_new:N \l__fun_variable_name_b_str
@@ -541,6 +659,10 @@
\__fun_group_begin:
}
+%%% --------------------------------------------------------
+%%> \subsection{Setting Functional Package}
+%%% --------------------------------------------------------
+
\bool_new:N \l__fun_scoping_bool
\cs_new_protected:Npn \__fun_scoping_true:
@@ -615,15 +737,6 @@
\Functional { scoping = false, tracing = false }
-\cs_new_protected:Npn \__fun_ignore_spaces_on:
- {
- \ExplSyntaxOn
- \char_set_catcode_math_subscript:N \_
- \char_set_catcode_other:N \:
- }
-\cs_set_eq:NN \IgnoreSpacesOn \__fun_ignore_spaces_on:
-\cs_set_eq:NN \IgnoreSpacesOff \ExplSyntaxOff
-
%%% --------------------------------------------------------
%%> \section{Interfaces for Argument Using (Use)}
%%% --------------------------------------------------------
@@ -632,23 +745,45 @@
{
\exp_args:Nc \__fun_put_result:n { #1 }
}
+\PrgNewFunction \ExpName { m }
+ {
+ \exp_args:Nc \__fun_put_result:n { #1 }
+ }
\PrgNewFunction \Value { M }
{
\__fun_put_result:V #1
}
+\PrgNewFunction \ExpValue { M }
+ {
+ \__fun_put_result:V #1
+ }
\PrgNewFunction \Expand { m }
{
\__fun_put_result:e { #1 }
}
+\PrgNewFunction \ExpWhole { m }
+ {
+ \__fun_put_result:e { #1 }
+ }
+
+\PrgNewFunction \ExpPartial { m }
+ {
+ \__fun_put_result:f { #1 }
+ }
+
+\PrgNewFunction \ExpOnce { m }
+ {
+ \__fun_put_result:o { #1 }
+ }
\cs_set_eq:NN \UnExpand \exp_not:n
\cs_set_eq:NN \NoExpand \exp_not:N
\cs_set_eq:NN \OnlyName \exp_not:c
\cs_set_eq:NN \OnlyValue \exp_not:V
-\cs_set_eq:NN \OnlyExpandF \exp_not:f
-\cs_set_eq:NN \OnlyExpandO \exp_not:o
+\cs_set_eq:NN \OnlyPartial \exp_not:f
+\cs_set_eq:NN \OnlyOnce \exp_not:o
\PrgNewFunction \UseOne { n } { \Return { #1 } }
@@ -665,21 +800,21 @@
\bool_const:Nn \cTrueBool { \c_true_bool }
\bool_const:Nn \cFalseBool { \c_false_bool }
-\bool_new:N \lTmpaBool \bool_new:N \lTmpbBool \bool_new:N \lTmpcBool
-\bool_new:N \lTmpiBool \bool_new:N \lTmpjBool \bool_new:N \lTmpkBool
-\bool_new:N \l@Funx@Bool \bool_new:N \l@Funy@Bool \bool_new:N \l@Funz@Bool
+\bool_new:N \lTmpaBool \bool_new:N \lTmpbBool \bool_new:N \lTmpcBool
+\bool_new:N \lTmpiBool \bool_new:N \lTmpjBool \bool_new:N \lTmpkBool
+\bool_new:N \l@FunTmpxBool \bool_new:N \l@FunTmpyBool \bool_new:N \l@FunTmpzBool
-\bool_new:N \gTmpaBool \bool_new:N \gTmpbBool \bool_new:N \gTmpcBool
-\bool_new:N \gTmpiBool \bool_new:N \gTmpjBool \bool_new:N \gTmpkBool
-\bool_new:N \g@Funx@Bool \bool_new:N \g@Funy@Bool \bool_new:N \g@Funz@Bool
+\bool_new:N \gTmpaBool \bool_new:N \gTmpbBool \bool_new:N \gTmpcBool
+\bool_new:N \gTmpiBool \bool_new:N \gTmpjBool \bool_new:N \gTmpkBool
+\bool_new:N \g@FunTmpxBool \bool_new:N \g@FunTmpyBool \bool_new:N \g@FunTmpzBool
\PrgNewFunction \BoolNew { M } { \bool_new:N #1 }
-\PrgNewFunction \BoolConst { M m } { \bool_const:Nn #1 { #2 } }
+\PrgNewFunction \BoolConst { M e } { \bool_const:Nn #1 {#2} }
-\PrgNewFunction \BoolSet { M m } {
+\PrgNewFunction \BoolSet { M e } {
\__fun_do_assignment:Nnn #1
- { \bool_gset:Nn #1 { #2 } } { \bool_set:Nn #1 { #2 } }
+ { \bool_gset:Nn #1 {#2} } { \bool_set:Nn #1 {#2} }
}
\PrgNewFunction \BoolSetTrue { M }
@@ -698,11 +833,11 @@
{ \bool_gset_eq:NN #1 #2 } { \bool_set_eq:NN #1 #2 }
}
-\PrgNewFunction \BoolLog { m } { \bool_log:n { #1 } }
+\PrgNewFunction \BoolLog { e } { \bool_log:n {#1} }
\PrgNewFunction \BoolVarLog { M } { \bool_log:N #1 }
-\PrgNewFunction \BoolShow { m } { \bool_show:n { #1 } }
+\PrgNewFunction \BoolShow { e } { \bool_show:n {#1} }
\PrgNewFunction \BoolVarShow { M } { \bool_show:N #1 }
@@ -711,7 +846,7 @@
\bool_if_exist:NTF #1 { \Return { \cTrueBool } } { \Return { \cFalseBool } }
}
-\PrgNewConditional \BoolVarIf { M } { \Return { #1 } }
+\PrgNewConditional \BoolVarIf { M } { \Return {#1} }
\PrgNewConditional \BoolVarNot { M }
{
@@ -765,13 +900,13 @@
\tl_set_eq:NN \cSpaceTl \c_space_tl
\tl_set_eq:NN \cNoValueTl \c_novalue_tl
-\tl_new:N \lTmpaTl \tl_new:N \lTmpbTl \tl_new:N \lTmpcTl
-\tl_new:N \lTmpiTl \tl_new:N \lTmpjTl \tl_new:N \lTmpkTl
-\tl_new:N \l@Funx@Tl \tl_new:N \l@Funy@Tl \tl_new:N \l@Funz@Tl
+\tl_new:N \lTmpaTl \tl_new:N \lTmpbTl \tl_new:N \lTmpcTl
+\tl_new:N \lTmpiTl \tl_new:N \lTmpjTl \tl_new:N \lTmpkTl
+\tl_new:N \l@FunTmpxTl \tl_new:N \l@FunTmpyTl \tl_new:N \l@FunTmpzTl
-\tl_new:N \gTmpaTl \tl_new:N \gTmpbTl \tl_new:N \gTmpcTl
-\tl_new:N \gTmpiTl \tl_new:N \gTmpjTl \tl_new:N \gTmpkTl
-\tl_new:N \g@Funx@Tl \tl_new:N \g@Funy@Tl \tl_new:N \g@Funz@Tl
+\tl_new:N \gTmpaTl \tl_new:N \gTmpbTl \tl_new:N \gTmpcTl
+\tl_new:N \gTmpiTl \tl_new:N \gTmpjTl \tl_new:N \gTmpkTl
+\tl_new:N \g@FunTmpxTl \tl_new:N \g@FunTmpyTl \tl_new:N \g@FunTmpzTl
\PrgNewFunction \TlNew { M } { \tl_new:N #1 }
@@ -973,13 +1108,13 @@
\str_set_eq:NN \cUnderscoreStr \c_underscore_str
\str_set_eq:NN \cZeroStr \c_zero_str
-\str_new:N \lTmpaStr \str_new:N \lTmpbStr \str_new:N \lTmpcStr
-\str_new:N \lTmpiStr \str_new:N \lTmpjStr \str_new:N \lTmpkStr
-\str_new:N \l@Funx@Str \str_new:N \l@Funy@Str \str_new:N \l@Funz@Str
+\str_new:N \lTmpaStr \str_new:N \lTmpbStr \str_new:N \lTmpcStr
+\str_new:N \lTmpiStr \str_new:N \lTmpjStr \str_new:N \lTmpkStr
+\str_new:N \l@FunTmpxStr \str_new:N \l@FunTmpyStr \str_new:N \l@FunTmpzStr
-\str_new:N \gTmpaStr \str_new:N \gTmpbStr \str_new:N \gTmpcStr
-\str_new:N \gTmpiStr \str_new:N \gTmpjStr \str_new:N \gTmpkStr
-\str_new:N \g@Funx@Str \str_new:N \g@Funy@Str \str_new:N \g@Funz@Str
+\str_new:N \gTmpaStr \str_new:N \gTmpbStr \str_new:N \gTmpcStr
+\str_new:N \gTmpiStr \str_new:N \gTmpjStr \str_new:N \gTmpkStr
+\str_new:N \g@FunTmpxStr \str_new:N \g@FunTmpyStr \str_new:N \g@FunTmpzStr
\PrgNewFunction \StrNew { M } { \str_new:N #1 }
@@ -1162,74 +1297,56 @@
\cs_set_eq:NN \cMaxRegisterInt \c_max_register_int
\cs_set_eq:NN \cMaxCharInt \c_max_char_in
-\int_new:N \lTmpaInt \int_new:N \lTmpbInt \int_new:N \lTmpcInt
-\int_new:N \lTmpiInt \int_new:N \lTmpjInt \int_new:N \lTmpkInt
-\int_new:N \l@Funx@Int \int_new:N \l@Funy@Int \int_new:N \l@Funz@Int
+\int_new:N \lTmpaInt \int_new:N \lTmpbInt \int_new:N \lTmpcInt
+\int_new:N \lTmpiInt \int_new:N \lTmpjInt \int_new:N \lTmpkInt
+\int_new:N \l@FunTmpxInt \int_new:N \l@FunTmpyInt \int_new:N \l@FunTmpzInt
-\int_new:N \gTmpaInt \int_new:N \gTmpbInt \int_new:N \gTmpcInt
-\int_new:N \gTmpiInt \int_new:N \gTmpjInt \int_new:N \gTmpkInt
-\int_new:N \g@Funx@Int \int_new:N \g@Funy@Int \int_new:N \g@Funz@Int
+\int_new:N \gTmpaInt \int_new:N \gTmpbInt \int_new:N \gTmpcInt
+\int_new:N \gTmpiInt \int_new:N \gTmpjInt \int_new:N \gTmpkInt
+\int_new:N \g@FunTmpxInt \int_new:N \g@FunTmpyInt \int_new:N \g@FunTmpzInt
-\PrgNewFunction \IntEval { m }
- {
- \Return { \Expand { \int_eval:n { #1 } } }
- }
+\PrgNewFunction \IntEval { e } { \Expand { \int_eval:n {#1} } }
-\PrgNewFunction \IntMathAdd { m m }
- {
- \int_set:Nn \l@Funx@Int { \int_eval:n { (#1) + (#2) } }
- \Return { \Value \l@Funx@Int }
- }
+\PrgNewFunction \IntMathAdd { e e } { \Expand { \int_eval:n { (#1) + (#2) } } }
-\PrgNewFunction \IntMathSub { m m }
- {
- \int_set:Nn \l@Funx@Int { \int_eval:n { (#1) - (#2) } }
- \Return { \Value \l@Funx@Int }
- }
+\PrgNewFunction \IntMathSub { e e } { \Expand { \int_eval:n { (#1) - (#2) } } }
-\PrgNewFunction \IntMathMult { m m }
- {
- \int_set:Nn \l@Funx@Int { \int_eval:n { (#1) * (#2) } }
- \Return { \Value \l@Funx@Int }
- }
+\PrgNewFunction \IntMathMult { e e } { \Expand { \int_eval:n { (#1) * (#2) } } }
-\PrgNewFunction \IntMathDiv { m m }
- {
- \Expand { \int_div_round:nn { #1 } { #2 } }
- }
+\PrgNewFunction \IntMathDiv { e e } { \Expand { \int_div_round:nn {#1} {#2} } }
-\PrgNewFunction \IntMathDivTruncate { m m }
+\PrgNewFunction \IntMathDivTruncate { e e }
{
- \Expand { \int_div_truncate:nn { #1 } { #2 } }
+ \Expand { \int_div_truncate:nn {#1} {#2} }
}
-\PrgNewFunction \IntMathSign { m } { \Expand { \int_sign:n { #1 } } }
+\PrgNewFunction \IntMathSign { e } { \Expand { \int_sign:n {#1} } }
-\PrgNewFunction \IntMathAbs { m } { \Expand { \int_abs:n { #1 } } }
+\PrgNewFunction \IntMathAbs { e } { \Expand { \int_abs:n {#1} } }
-\PrgNewFunction \IntMathMax { m m } { \Expand { \int_max:nn { #1 } { #2 } } }
+\PrgNewFunction \IntMathMax { e e } { \Expand { \int_max:nn {#1} {#2} } }
-\PrgNewFunction \IntMathMin { m m } { \Expand { \int_min:nn { #1 } { #2 } } }
+\PrgNewFunction \IntMathMin { e e } { \Expand { \int_min:nn {#1} {#2} } }
-\PrgNewFunction \IntMathMod { m m } { \Expand { \int_mod:nn { #1 } { #2 } } }
+\PrgNewFunction \IntMathMod { e e } { \Expand { \int_mod:nn {#1} {#2} } }
-\PrgNewFunction \IntMathRand { m m } { \Expand { \int_rand:nn { #1 } { #2 } } }
+\PrgNewFunction \IntMathRand { e e } { \Expand { \int_rand:nn {#1} {#2} } }
\PrgNewFunction \IntNew { M } { \int_new:N #1 }
-\PrgNewFunction \IntConst { M m } { \int_const:Nn #1 { #2 } }
+\PrgNewFunction \IntConst { M e } { \int_const:Nn #1 { #2 } }
-\PrgNewFunction \IntLog { m } { \int_log:n { #1 } }
+\PrgNewFunction \IntLog { e } { \int_log:n { #1 } }
\PrgNewFunction \IntVarLog { M } { \int_log:N #1 }
-\PrgNewFunction \IntShow { m } { \int_show:n { #1 } }
+\PrgNewFunction \IntShow { e } { \int_show:n { #1 } }
\PrgNewFunction \IntVarShow { M } { \int_show:N #1 }
\PrgNewFunction \IntUse { M } { \Return { \Value #1 } }
-\PrgNewFunction \IntSet { M m }
+\PrgNewFunction \IntSet { M e }
{
\__fun_do_assignment:Nnn #1 { \int_gset:Nn #1 {#2} } { \int_set:Nn #1 {#2} }
}
@@ -1259,24 +1376,40 @@
\__fun_do_assignment:Nnn #1 { \int_gdecr:N #1 } { \int_decr:N #1 }
}
-\PrgNewFunction \IntAdd { M m }
+\PrgNewFunction \IntAdd { M e }
{
\__fun_do_assignment:Nnn #1 { \int_gadd:Nn #1 {#2} } { \int_add:Nn #1 {#2} }
}
-\PrgNewFunction \IntSub { M m }
+\PrgNewFunction \IntSub { M e }
{
\__fun_do_assignment:Nnn #1 { \int_gsub:Nn #1 {#2} } { \int_sub:Nn #1 {#2} }
}
-\PrgNewFunction \IntStepInline { m m m n }
+%% Command \prg_replicate:nn yields its result after two expansion steps
+\PrgNewFunction \IntReplicate { e m }
+ {
+ \exp_args:NNo \exp_args:No \Return { \prg_replicate:nn {#1} {#2} }
+ }
+
+\PrgNewFunction \IntStepInline { e e e n }
+ {
+ \int_step_inline:nnnn {#1} {#2} {#3} {#4}
+ }
+
+\PrgNewFunction \IntStepOneInline { e e n }
+ {
+ \int_step_inline:nnn {#1} {#2} {#3}
+ }
+
+\PrgNewFunction \IntStepVariable { e e e M n }
{
- \int_step_inline:nnnn { #1 } { #2 } { #3 } { #4 }
+ \int_step_variable:nnnNn {#1} {#2} {#3} #4 {#5}
}
-\PrgNewFunction \IntStepVariable { m m m M n }
+\PrgNewFunction \IntStepOneVariable { e e M n }
{
- \int_step_variable:nnnNn { #1 } { #2 } { #3 } #4 { #5 }
+ \int_step_variable:nnNn {#1} {#2} #3 {#4}
}
\PrgNewConditional \IntIfExist { M }
@@ -1284,27 +1417,27 @@
\int_if_exist:NTF #1 { \Return { \cTrueBool } } { \Return { \cFalseBool } }
}
-\PrgNewConditional \IntIfOdd { m }
+\PrgNewConditional \IntIfOdd { e }
{
\int_if_odd:nTF { #1 } { \Return { \cTrueBool } } { \Return { \cFalseBool } }
}
-\PrgNewConditional \IntIfEven { m }
+\PrgNewConditional \IntIfEven { e }
{
\int_if_even:nTF { #1 } { \Return { \cTrueBool } } { \Return { \cFalseBool } }
}
-\PrgNewConditional \IntCompare { m N m }
+\PrgNewConditional \IntCompare { e N e }
{
\int_compare:nNnTF {#1} #2 {#3}
{ \Return { \cTrueBool } }
{ \Return { \cFalseBool } }
}
-\PrgNewFunction \IntCase { m m } { \int_case:nn {#1} {#2} }
-\PrgNewFunction \IntCaseT { m m n } { \int_case:nnT {#1} {#2} {#3} }
-\PrgNewFunction \IntCaseF { m m n } { \int_case:nnF {#1} {#2} {#3} }
-\PrgNewFunction \IntCaseTF { m m n n } { \int_case:nnTF {#1} {#2} {#3} {#4} }
+\PrgNewFunction \IntCase { e m } { \int_case:nn {#1} {#2} }
+\PrgNewFunction \IntCaseT { e m n } { \int_case:nnT {#1} {#2} {#3} }
+\PrgNewFunction \IntCaseF { e m n } { \int_case:nnF {#1} {#2} {#3} }
+\PrgNewFunction \IntCaseTF { e m n n } { \int_case:nnTF {#1} {#2} {#3} {#4} }
%%% --------------------------------------------------------
%%> \section{Interfaces for Floating Point Numbers (Fp)}
@@ -1319,78 +1452,47 @@
\fp_set_eq:NN \cPiFp \c_pi_fp
\fp_set_eq:NN \cOneDegreeFp \c_one_degree_fp
-\fp_new:N \lTmpaFp \fp_new:N \lTmpbFp \fp_new:N \lTmpcFp
-\fp_new:N \lTmpiFp \fp_new:N \lTmpjFp \fp_new:N \lTmpkFp
-\fp_new:N \l@Funx@Fp \fp_new:N \l@Funy@Fp \fp_new:N \l@Funz@Fp
+\fp_new:N \lTmpaFp \fp_new:N \lTmpbFp \fp_new:N \lTmpcFp
+\fp_new:N \lTmpiFp \fp_new:N \lTmpjFp \fp_new:N \lTmpkFp
+\fp_new:N \l@FunTmpxFp \fp_new:N \l@FunTmpyFp \fp_new:N \l@FunTmpzFp
-\fp_new:N \gTmpaFp \fp_new:N \gTmpbFp \fp_new:N \gTmpcFp
-\fp_new:N \gTmpiFp \fp_new:N \gTmpjFp \fp_new:N \gTmpkFp
-\fp_new:N \g@Funx@Fp \fp_new:N \g@Funy@Fp \fp_new:N \g@Funz@Fp
+\fp_new:N \gTmpaFp \fp_new:N \gTmpbFp \fp_new:N \gTmpcFp
+\fp_new:N \gTmpiFp \fp_new:N \gTmpjFp \fp_new:N \gTmpkFp
+\fp_new:N \g@FunTmpxFp \fp_new:N \g@FunTmpyFp \fp_new:N \g@FunTmpzFp
-\PrgNewFunction \FpEval { m }
- {
- \Return { \Expand { \fp_eval:n { #1 } } }
- }
+\PrgNewFunction \FpEval { e } { \Expand { \fp_eval:n {#1} } }
-\PrgNewFunction \FpMathAdd { m m }
- {
- \fp_set:Nn \l@Funx@Fp { \fp_eval:n { (#1) + (#2) } }
- \Return { \FpUse \l@Funx@Fp }
- }
+\PrgNewFunction \FpMathAdd { e e } { \Expand { \fp_eval:n { (#1) + (#2) } } }
-\PrgNewFunction \FpMathSub { m m }
- {
- \fp_set:Nn \l@Funx@Fp { \fp_eval:n { (#1) - (#2) } }
- \Return { \FpUse \l@Funx@Fp }
- }
+\PrgNewFunction \FpMathSub { e e } { \Expand { \fp_eval:n { (#1) - (#2) } } }
-\PrgNewFunction \FpMathMult { m m }
- {
- \fp_set:Nn \l@Funx@Fp { \fp_eval:n { (#1) * (#2) } }
- \Return { \FpUse \l@Funx@Fp }
- }
+\PrgNewFunction \FpMathMult { e e } { \Expand { \fp_eval:n { (#1) * (#2) } } }
-\PrgNewFunction \FpMathDiv { m m }
- {
- \fp_set:Nn \l@Funx@Fp { \fp_eval:n { (#1) / (#2) } }
- \Return { \FpUse \l@Funx@Fp }
- }
+\PrgNewFunction \FpMathDiv { e e } { \Expand { \fp_eval:n { (#1) / (#2) } } }
-\PrgNewFunction \FpMathSign { m }
- {
- \Return { \Expand { \fp_sign:n { #1 } } }
- }
+\PrgNewFunction \FpMathSign { e } { \Expand { \fp_sign:n {#1} } }
-\PrgNewFunction \FpMathAbs { m }
- {
- \Return { \Expand { \fp_abs:n { #1 } } }
- }
+\PrgNewFunction \FpMathAbs { e } { \Expand { \fp_abs:n {#1} } }
-\PrgNewFunction \FpMathMax { m m }
- {
- \Return { \Expand { \fp_max:nn { #1 } { #2 } } }
- }
+\PrgNewFunction \FpMathMax { e e } { \Expand { \fp_max:nn {#1} {#2} } }
-\PrgNewFunction \FpMathMin { m m }
- {
- \Return { \Expand { \fp_min:nn { #1 } { #2 } } }
- }
+\PrgNewFunction \FpMathMin { e e } { \Expand { \fp_min:nn {#1} {#2} } }
\PrgNewFunction \FpNew { M } { \fp_new:N #1 }
-\PrgNewFunction \FpConst { M m } { \fp_const:Nn #1 {#2} }
+\PrgNewFunction \FpConst { M e } { \fp_const:Nn #1 {#2} }
-\PrgNewFunction \FpUse { M } { \Return { \Expand { \fp_use:N #1 } } }
+\PrgNewFunction \FpUse { M } { \Expand { \fp_use:N #1 } }
-\PrgNewFunction \FpLog { m } { \fp_log:n { #1 } }
+\PrgNewFunction \FpLog { e } { \fp_log:n {#1} }
\PrgNewFunction \FpVarLog { M } { \fp_log:N #1 }
-\PrgNewFunction \FpShow { m } { \fp_show:n { #1 } }
+\PrgNewFunction \FpShow { e } { \fp_show:n {#1} }
\PrgNewFunction \FpVarShow { M } { \fp_show:N #1 }
-\PrgNewFunction \FpSet { M m }
+\PrgNewFunction \FpSet { M e }
{
\__fun_do_assignment:Nnn #1 { \fp_gset:Nn #1 {#2} } { \fp_set:Nn #1 {#2} }
}
@@ -1410,24 +1512,24 @@
\__fun_do_assignment:Nnn #1 { \fp_gzero_new:N #1 } { \fp_zero_new:N #1 }
}
-\PrgNewFunction \FpAdd { M m }
+\PrgNewFunction \FpAdd { M e }
{
\__fun_do_assignment:Nnn #1 { \fp_gadd:Nn #1 {#2} } { \fp_add:Nn #1 {#2} }
}
-\PrgNewFunction \FpSub { M m }
+\PrgNewFunction \FpSub { M e }
{
\__fun_do_assignment:Nnn #1 { \fp_gsub:Nn #1 {#2} } { \fp_sub:Nn #1 {#2} }
}
-\PrgNewFunction \FpStepInline { m m m n }
+\PrgNewFunction \FpStepInline { e e e n }
{
- \fp_step_inline:nnnn { #1 } { #2 } { #3 } { #4 }
+ \fp_step_inline:nnnn {#1} {#2} {#3} {#4}
}
-\PrgNewFunction \FpStepVariable { m m m M n }
+\PrgNewFunction \FpStepVariable { e e e M n }
{
- \fp_step_variable:nnnNn { #1 } { #2 } { #3 } #4 { #5 }
+ \fp_step_variable:nnnNn {#1} {#2} {#3} #4 {#5}
}
\PrgNewConditional \FpIfExist { M }
@@ -1435,7 +1537,7 @@
\fp_if_exist:NTF #1 { \Return { \cTrueBool } } { \Return { \cFalseBool } }
}
-\PrgNewConditional \FpCompare { m N m }
+\PrgNewConditional \FpCompare { e N e }
{
\fp_compare:nNnTF {#1} #2 {#3}
{ \Return { \cTrueBool } }
@@ -1449,13 +1551,13 @@
\cs_set_eq:NN \cMaxDim \c_max_dim
\cs_set_eq:NN \cZeroDim \c_zero_dim
-\dim_new:N \lTmpaDim \dim_new:N \lTmpbDim \dim_new:N \lTmpcDim
-\dim_new:N \lTmpiDim \dim_new:N \lTmpjDim \dim_new:N \lTmpkDim
-\dim_new:N \l@Funx@Dim \dim_new:N \l@Funy@Dim \dim_new:N \l@Funz@Dim
+\dim_new:N \lTmpaDim \dim_new:N \lTmpbDim \dim_new:N \lTmpcDim
+\dim_new:N \lTmpiDim \dim_new:N \lTmpjDim \dim_new:N \lTmpkDim
+\dim_new:N \l@FunTmpxDim \dim_new:N \l@FunTmpyDim \dim_new:N \l@FunTmpzDim
-\dim_new:N \gTmpaDim \dim_new:N \gTmpbDim \dim_new:N \gTmpcDim
-\dim_new:N \gTmpiDim \dim_new:N \gTmpjDim \dim_new:N \gTmpkDim
-\dim_new:N \g@Funx@Dim \dim_new:N \g@Funy@Dim \dim_new:N \g@Funz@Dim
+\dim_new:N \gTmpaDim \dim_new:N \gTmpbDim \dim_new:N \gTmpcDim
+\dim_new:N \gTmpiDim \dim_new:N \gTmpjDim \dim_new:N \gTmpkDim
+\dim_new:N \g@FunTmpxDim \dim_new:N \g@FunTmpyDim \dim_new:N \g@FunTmpzDim
\PrgNewFunction \DimEval { m }
{
@@ -1464,14 +1566,14 @@
\PrgNewFunction \DimMathAdd { m m }
{
- \dim_set:Nn \l@Funx@Dim { \dim_eval:n { (#1) + (#2) } }
- \Return { \Value \l@Funx@Dim }
+ \dim_set:Nn \l@FunTmpxDim { \dim_eval:n { (#1) + (#2) } }
+ \Return { \Value \l@FunTmpxDim }
}
\PrgNewFunction \DimMathSub { m m }
{
- \dim_set:Nn \l@Funx@Dim { \dim_eval:n { (#1) - (#2) } }
- \Return { \Value \l@Funx@Dim }
+ \dim_set:Nn \l@FunTmpxDim { \dim_eval:n { (#1) - (#2) } }
+ \Return { \Value \l@FunTmpxDim }
}
\PrgNewFunction \DimMathSign { m }
@@ -1580,13 +1682,15 @@
%%> \section{Interfaces for Comma Separated Lists (Clist)}
%%% --------------------------------------------------------
-\clist_new:N \lTmpaClist \clist_new:N \lTmpbClist \clist_new:N \lTmpcClist
-\clist_new:N \lTmpiClist \clist_new:N \lTmpjClist \clist_new:N \lTmpkClist
-\clist_new:N \l@Funx@Clist \clist_new:N \l@Funy@Clist \clist_new:N \l@Funz@Clist
+\clist_new:N \lTmpaClist \clist_new:N \lTmpbClist \clist_new:N \lTmpcClist
+\clist_new:N \lTmpiClist \clist_new:N \lTmpjClist \clist_new:N \lTmpkClist
+
+\clist_new:N \gTmpaClist \clist_new:N \gTmpbClist \clist_new:N \gTmpcClist
+\clist_new:N \gTmpiClist \clist_new:N \gTmpjClist \clist_new:N \gTmpkClist
-\clist_new:N \gTmpaClist \clist_new:N \gTmpbClist \clist_new:N \gTmpcClist
-\clist_new:N \gTmpiClist \clist_new:N \gTmpjClist \clist_new:N \gTmpkClist
-\clist_new:N \g@Funx@Clist \clist_new:N \g@Funy@Clist \clist_new:N \g@Funz@Clist
+\clist_new:N \l@FunTmpxClist \clist_new:N \g@FunTmpxClist
+\clist_new:N \l@FunTmpyClist \clist_new:N \g@FunTmpyClist
+\clist_new:N \l@FunTmpzClist \clist_new:N \g@FunTmpzClist
\clist_set_eq:NN \cEmptyClist \c_empty_clist
@@ -1793,13 +1897,13 @@
%%> \section{Interfaces for Sequences and Stacks (Seq)}
%%% --------------------------------------------------------
-\seq_new:N \lTmpaSeq \seq_new:N \lTmpbSeq \seq_new:N \lTmpcSeq
-\seq_new:N \lTmpiSeq \seq_new:N \lTmpjSeq \seq_new:N \lTmpkSeq
-\seq_new:N \l@Funx@Seq \seq_new:N \l@Funy@Seq \seq_new:N \l@Funz@Seq
+\seq_new:N \lTmpaSeq \seq_new:N \lTmpbSeq \seq_new:N \lTmpcSeq
+\seq_new:N \lTmpiSeq \seq_new:N \lTmpjSeq \seq_new:N \lTmpkSeq
+\seq_new:N \l@FunTmpxSeq \seq_new:N \l@FunTmpySeq \seq_new:N \l@FunTmpzSeq
-\seq_new:N \gTmpaSeq \seq_new:N \gTmpbSeq \seq_new:N \gTmpcSeq
-\seq_new:N \gTmpiSeq \seq_new:N \gTmpjSeq \seq_new:N \gTmpkSeq
-\seq_new:N \g@Funx@Seq \seq_new:N \g@Funy@Seq \seq_new:N \g@Funz@Seq
+\seq_new:N \gTmpaSeq \seq_new:N \gTmpbSeq \seq_new:N \gTmpcSeq
+\seq_new:N \gTmpiSeq \seq_new:N \gTmpjSeq \seq_new:N \gTmpkSeq
+\seq_new:N \g@FunTmpxSeq \seq_new:N \g@FunTmpySeq \seq_new:N \g@FunTmpzSeq
\seq_set_eq:NN \cEmptySeq \c_empty_seq
@@ -2039,13 +2143,13 @@
%%> \section{Interfaces for Property Lists (Prop)}
%%% --------------------------------------------------------
-\prop_new:N \lTmpaProp \prop_new:N \lTmpbProp \prop_new:N \lTmpcProp
-\prop_new:N \lTmpiProp \prop_new:N \lTmpjProp \prop_new:N \lTmpkProp
-\prop_new:N \l@Funx@Prop \prop_new:N \l@Funy@Prop \prop_new:N \l@Funz@Prop
+\prop_new:N \lTmpaProp \prop_new:N \lTmpbProp \prop_new:N \lTmpcProp
+\prop_new:N \lTmpiProp \prop_new:N \lTmpjProp \prop_new:N \lTmpkProp
+\prop_new:N \l@FunTmpxProp \prop_new:N \l@FunTmpyProp \prop_new:N \l@FunTmpzProp
-\prop_new:N \gTmpaProp \prop_new:N \gTmpbProp \prop_new:N \gTmpcProp
-\prop_new:N \gTmpiProp \prop_new:N \gTmpjProp \prop_new:N \gTmpkProp
-\prop_new:N \g@Funx@Prop \prop_new:N \g@Funy@Prop \prop_new:N \g@Funz@Prop
+\prop_new:N \gTmpaProp \prop_new:N \gTmpbProp \prop_new:N \gTmpcProp
+\prop_new:N \gTmpiProp \prop_new:N \gTmpjProp \prop_new:N \gTmpkProp
+\prop_new:N \g@FunTmpxProp \prop_new:N \g@FunTmpyProp \prop_new:N \g@FunTmpzProp
\prop_set_eq:NN \cEmptyProp \c_empty_prop
@@ -2172,6 +2276,173 @@
}
%%% --------------------------------------------------------
+%%> \section{Interfaces for Token Manipulation (Token)}
+%%% --------------------------------------------------------
+
+\PrgNewFunction \CharLowercase { M }
+ {
+ \Expand { \char_lowercase:N #1 }
+ }
+
+\PrgNewFunction \CharUppercase { M }
+ {
+ \Expand { \char_uppercase:N #1 }
+ }
+
+\PrgNewFunction \CharTitlecase { M }
+ {
+ \Expand { \char_titlecase:N #1 }
+ }
+
+\PrgNewFunction \CharFoldcase { M }
+ {
+ \Expand { \char_foldcase:N #1 }
+ }
+
+\PrgNewFunction \CharStrLowercase { M }
+ {
+ \Expand { \char_str_lowercase:N #1 }
+ }
+
+\PrgNewFunction \CharStrUppercase { M }
+ {
+ \Expand { \char_str_uppercase:N #1 }
+ }
+
+\PrgNewFunction \CharStrTitlecase { M }
+ {
+ \Expand { \char_str_titlecase:N #1 }
+ }
+
+\PrgNewFunction \CharStrFoldcase { M }
+ {
+ \Expand { \char_str_foldcase:N #1 }
+ }
+
+\PrgNewFunction \CharSetLccode { m m }
+ {
+ \char_set_lccode:nn {#1} {#2}
+ }
+
+\PrgNewFunction \CharValueLccode { m }
+ {
+ \Expand { \char_value_lccode:n {#1} }
+ }
+
+\PrgNewFunction \CharSetUccode { m m }
+ {
+ \char_set_uccode:nn {#1} {#2}
+ }
+
+\PrgNewFunction \CharValueUccode { m }
+ {
+ \Expand { \char_value_uccode:n {#1} }
+ }
+
+%%% --------------------------------------------------------
+%%> \section{Interfaces for Text Processing (Text)}
+%%% --------------------------------------------------------
+
+\PrgNewFunction \TextExpand { m }
+ {
+ \Expand { \text_expand:n {#1} }
+ }
+
+\PrgNewFunction \TextLowercase { m }
+ {
+ \Expand { \text_lowercase:n {#1} }
+ }
+
+\PrgNewFunction \TextUppercase { m }
+ {
+ \Expand { \text_uppercase:n {#1} }
+ }
+
+\PrgNewFunction \TextTitlecase { m }
+ {
+ \Expand { \text_titlecase:n {#1} }
+ }
+
+\PrgNewFunction \TextTitlecaseFirst { m }
+ {
+ \Expand { \text_titlecase_first:n {#1} }
+ }
+
+\PrgNewFunction \TextLangLowercase { m m }
+ {
+ \Expand { \text_lowercase:nn {#1} {#2} }
+ }
+
+\PrgNewFunction \TextLangUppercase { m m }
+ {
+ \Expand { \text_uppercase:nn {#1} {#2} }
+ }
+
+\PrgNewFunction \TextLangTitlecase { m m }
+ {
+ \Expand { \text_titlecase:nn {#1} {#2} }
+ }
+
+\PrgNewFunction \TextLangTitlecaseFirst { m m }
+ {
+ \Expand { \text_titlecase_first:nn {#1} {#2} }
+ }
+
+%%% --------------------------------------------------------
+%%> \section{Interfaces for Files (File)}
+%%% --------------------------------------------------------
+
+\msg_new:nnn { functional } { file-not-found } { File ~ "#1" ~ not ~ found! }
+
+\PrgNewFunction \FileInput { m }
+ {
+ \file_get:nnN {#1} {} \l@FunTmpxTl
+ \quark_if_no_value:NTF \l@FunTmpxTl
+ { \msg_error:nnn { functional } { file-not-found } { #1 } }
+ { \TlUse \l@FunTmpxTl }
+ }
+
+\PrgNewFunction \FileIfExistInput { m }
+ {
+ \file_get:nnN {#1} {} \l@FunTmpxTl
+ \quark_if_no_value:NF \l@FunTmpxTl { \TlUse \l@FunTmpxTl }
+ }
+
+\PrgNewFunction \FileIfExistInputF { m n }
+ {
+ \file_get:nnN {#1} {} \l@FunTmpxTl
+ \quark_if_no_value:NTF \l@FunTmpxTl { #2 } { \TlUse \l@FunTmpxTl }
+ }
+
+\cs_set_eq:NN \FileInputStop \file_input_stop:
+
+\PrgNewFunction \FileGet { m m M }
+ {
+ \file_get:nnN {#1} {#2} #3
+ \__fun_quark_upgrade_no_value:N #3
+ }
+
+\PrgNewFunction \FileGetT { m m M n }
+ {
+ \file_get:nnNT {#1} {#2} #3 {#4}
+ }
+
+\PrgNewFunction \FileGetF { m m M n }
+ {
+ \file_get:nnNF {#1} {#2} #3 {#4}
+ }
+
+\PrgNewFunction \FileGetTF { m m M n n }
+ {
+ \file_get:nnNTF {#1} {#2} #3 {#4} {#5}
+ }
+
+\PrgNewConditional \FileIfExist { m }
+ {
+ \file_if_exist:nTF {#1} { \Return { \cTrueBool } } { \Return { \cFalseBool } }
+ }
+
+%%% --------------------------------------------------------
%%> \section{Interfaces for Quarks (Quark)}
%%% --------------------------------------------------------