summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/functional/functional.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/functional/functional.tex')
-rw-r--r--macros/latex/contrib/functional/functional.tex679
1 files changed, 469 insertions, 210 deletions
diff --git a/macros/latex/contrib/functional/functional.tex b/macros/latex/contrib/functional/functional.tex
index 9f8026fd56..8c8e3a5e84 100644
--- a/macros/latex/contrib/functional/functional.tex
+++ b/macros/latex/contrib/functional/functional.tex
@@ -3,7 +3,7 @@
\documentclass[oneside]{book}
\usepackage[a4paper,margin=2.5cm]{geometry}
-\newcommand*{\myversion}{2022C}
+\newcommand*{\myversion}{2022D}
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
@@ -133,7 +133,7 @@ We will compare our first example with a similar \verb!Lua! example:
\IgnoreSpacesOn
\PrgNewFunction \MathSquare { m } {
\IntSet \lTmpaInt { \IntEval {#1 * #1} }
- \Result { \Value \lTmpaInt }
+ \Return { \Value \lTmpaInt }
}
\IgnoreSpacesOff
\MathSquare{5}
@@ -156,7 +156,7 @@ print(MathSquare(MathSquare(5)))
%\IgnoreSpacesOn
%\PrgNewFunction \MathSquare { m }{
% \IntSet \lTmpaInt { \IntEval { #1 * #1 } }
-% \Result { \Value \lTmpaInt }
+% \Return { \Value \lTmpaInt }
%}
%\IgnoreSpacesOff
%\MathSquare{5}
@@ -166,7 +166,7 @@ print(MathSquare(MathSquare(5)))
%\PrgNewFunction \MathCubic { m }
% {
% \IntSet \lTmpaInt { \IntEval { #1 * #1 * #1 } }
-% \Result { \Value \lTmpaInt }
+% \Return { \Value \lTmpaInt }
% }
%\IgnoreSpacesOff
%\MathCubic{2}
@@ -183,7 +183,7 @@ You can define new functions with \cs{PrgNewFunction} command.
To make composition of functions work as expected,
every function \emph{must not} insert directly any token to the input stream.
Instead, a function \emph{must} pass the result (if any) to \verb!functional! package
-with \cs{Result} command. And \verb!functional! package is responsible for
+with \cs{Return} command. And \verb!functional! package is responsible for
inserting result tokens to the input stream at the appropriate time.
To remove space tokens inside function code in defining functions,
@@ -198,9 +198,9 @@ we will compare our factorial example with a similar \verb!Lua! example:
\IgnoreSpacesOn
\PrgNewFunction \Fact { m } {
\IntCompareTF {#1} = {0} {
- \Result {1}
+ \Return {1}
}{
- \Result {\IntMathMult{#1}{\Fact{\IntMathSub{#1}{1}}}}
+ \Return {\IntMathMult{#1}{\Fact{\IntMathSub{#1}{1}}}}
}
}
\IgnoreSpacesOff
@@ -225,9 +225,9 @@ print(Fact(4))
%\IgnoreSpacesOn
%\PrgNewFunction \Factorial { m } {
% \IntCompareTF {#1} = {0} {
-% \Result {1}
+% \Return {1}
% }{
-% \Result { \IntMathMult {#1} { \Factorial { \IntMathSub{#1}{1} } } }
+% \Return { \IntMathMult {#1} { \Factorial { \IntMathSub{#1}{1} } } }
% }
%}
%\IgnoreSpacesOff
@@ -349,14 +349,14 @@ For example, the tracing log of the first example in this chapter will be the fo
% [I] \IntEval{5*5}
% [I] \Expand{\int_eval:n {5*5}}
% [O] 25
-% [I] \Result{25}
+% [I] \Return{25}
% [O] 25
% [O] 25
% [I] \IntSet\lTmpaInt {25}
% [O]
% [I] \Value\lTmpaInt
% [O] 25
-% [I] \Result{25}
+% [I] \Return{25}
% [O] 25
% [O] 25
%\end{codehigh}
@@ -365,28 +365,28 @@ For example, the tracing log of the first example in this chapter will be the fo
[I] \IntEval{5*5}
[I] \Expand{\int_eval:n {5*5}}
[O] 25
- [I] \Result{25}
+ [I] \Return{25}
[O] 25
[O] 25
[I] \IntSet{\lTmpaInt }{25}
[O]
[I] \Value{\lTmpaInt }
[O] 25
- [I] \Result{25}
+ [I] \Return{25}
[O] 25
[O] 25
[I] \MathSquare{25}
[I] \IntEval{25*25}
[I] \Expand{\int_eval:n {25*25}}
[O] 625
- [I] \Result{625}
+ [I] \Return{625}
[O] 625
[O] 625
[I] \IntSet{\lTmpaInt }{625}
[O]
[I] \Value{\lTmpaInt }
[O] 625
- [I] \Result{625}
+ [I] \Return{625}
[O] 625
[O] 625
\end{codehigh}
@@ -488,7 +488,7 @@ simply composing \cs{Name} and \cs{Value} functions:
Creates protected \meta{function} for evaluating the \meta{code}.
Within the \meta{code}, the parameters (\verb|#1|, \verb|#2|,
\emph{etc.}) will be replaced by those absorbed by the function.
-The returned value \emph{must} be passed with \cs{Result} function.
+The returned value \emph{must} be passed with \cs{Return} function.
The definition is global and an error results if the
\meta{function} is already defined.\par
The \Arg{argument specification} in a list of letters,
@@ -513,7 +513,7 @@ the argument will be evaluated and replaced with the returned value.
\end{syntax}
Creates protected conditional \meta{function} for evaluating the \meta{code}.
The returned value of the \meta{function} \emph{must} be either \verb!\cTrueBool!
-or \verb!\cFalseBool! and be passed with \cs{Result} function..
+or \verb!\cFalseBool! and be passed with \cs{Return} function..
The definition is global and an error results if the \meta{function} is already defined.
\par
Assume the \meta{function} is \verb!\FooIfBar!, then another function \verb!\FooIfBarTF!
@@ -521,14 +521,35 @@ will be created at the same time. \verb!\FooIfBarTF! function has two extra argu
which are \Arg{true code} and \Arg{false code}.\par
\end{function}
-\section{Collecting Returned Values}
+\section{Return Values of Functions}
-\begin{function}{\Result}
+\begin{function}{\Return}
\begin{syntax}
-\cs{Result} \Arg{tokens}
+\cs{Return} \Arg{tokens}
\end{syntax}
-Appends \meta{tokens} to \verb!\gResultTl!, which holds the returned value of current function.
-This function is normally used in the \meta{code} of \cs{PrgNewFunction} and \cs{PrgNewConditional}.
+Returns \meta{tokens} as result of current function or conditional.
+This function is normally used in the \meta{code} of \cs{PrgNewFunction}
+or \cs{PrgNewConditional}, and it \emph{must} be the last function evaluated in the \meta{code}.
+If it is missing, the return value of the last function evaluated in the \meta{code}
+is returned. Therefore, the following two examples produce the same output:
+\begin{codehigh}
+\IgnoreSpacesOn
+\PrgNewFunction \MathSquare { m } {
+ \IntSet \lTmpaInt { \IntEval {#1 * #1} }
+ \Return { \Value \lTmpaInt }
+}
+\IgnoreSpacesOff
+\MathSquare{5}
+\end{codehigh}
+\begin{codehigh}
+\IgnoreSpacesOn
+\PrgNewFunction \MathSquare { m } {
+ \IntSet \lTmpaInt { \IntEval {#1 * #1} }
+ \Value \lTmpaInt
+}
+\IgnoreSpacesOff
+\MathSquare{5}
+\end{codehigh}
\end{function}
\chapter{Argument Using (\texttt{Use})}
@@ -660,8 +681,8 @@ For example
Constants that represent \verb|true| and \verb|false|, respectively. Used to
implement predicates. For example
\begin{demohigh}
-\BoolVarIfTF \cTrueBool {\Result{True!}} {\Result{False!}}
-\BoolVarIfTF \cFalseBool {\Result{True!}} {\Result{False!}}
+\BoolVarIfTF \cTrueBool {\Return{True!}} {\Return{False!}}
+\BoolVarIfTF \cFalseBool {\Return{True!}} {\Return{False!}}
\end{demohigh}
\end{variable}
@@ -776,51 +797,59 @@ Displays the logical truth of the \meta{boolean} on the terminal.
\section{Booleans and Conditionals}
-\begin{function}{\BoolIfExist,\BoolIfExistTF}
+\begin{function}{\BoolIfExist,\BoolIfExistT,\BoolIfExistF,\BoolIfExistTF}
\begin{syntax}
\cs{BoolIfExist} \meta{boolean}
+\cs{BoolIfExistT} \meta{boolean} \Arg{true code}
+\cs{BoolIfExistF} \meta{boolean} \Arg{false code}
\cs{BoolIfExistTF} \meta{boolean} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{boolean} is currently defined. This does not
check that the \meta{boolean} really is a boolean variable.
For example
\begin{demohigh}
-\BoolIfExistTF \lTmpaBool {\Result{Yes}} {\Result{No}}
-\BoolIfExistTF \lFooUndefinedBool {\Result{Yes}} {\Result{No}}
+\BoolIfExistTF \lTmpaBool {\Return{Yes}} {\Return{No}}
+\BoolIfExistTF \lFooUndefinedBool {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\BoolVarIf,\BoolVarIfTF}
+\begin{function}{\BoolVarIf,\BoolVarIfT,\BoolVarIfF,\BoolVarIfTF}
\begin{syntax}
\cs{BoolVarIf} \meta{boolean}
+\cs{BoolVarIfT} \meta{boolean} \Arg{true code}
+\cs{BoolVarIfF} \meta{boolean} \Arg{false code}
\cs{BoolVarIfTF} \meta{boolean} \Arg{true code} \Arg{false code}
\end{syntax}
Tests the current truth of \meta{boolean}, and continues evaluation
based on this result. For example
\begin{demohigh}
\BoolSetTrue \lTmpaBool
-\BoolVarIfTF \lTmpaBool {\Result{True!}} {\Result{False!}}
+\BoolVarIfTF \lTmpaBool {\Return{True!}} {\Return{False!}}
\BoolSetFalse \lTmpaBool
-\BoolVarIfTF \lTmpaBool {\Result{True!}} {\Result{False!}}
+\BoolVarIfTF \lTmpaBool {\Return{True!}} {\Return{False!}}
\end{demohigh}
\end{function}
-\begin{function}{\BoolVarNot,\BoolVarNotTF}
+\begin{function}{\BoolVarNot,\BoolVarNotT,\BoolVarNotF,\BoolVarNotTF}
\begin{syntax}
\cs{BoolVarNot} \meta{boolean}
+\cs{BoolVarNotT} \meta{boolean} \Arg{true code}
+\cs{BoolVarNotF} \meta{boolean} \Arg{false code}
\cs{BoolVarNotTF} \meta{boolean} \Arg{true code} \Arg{false code}
\end{syntax}
Evaluates \meta{true code} if \meta{boolean} is \verb!false!,
and \meta{false code} if \meta{boolean} is \verb!true!.
For example
\begin{demohigh}
-\BoolVarNotTF {\IntCompare{3}>{2}} {\Result{Yes}} {\Result{No}}
+\BoolVarNotTF {\IntCompare{3}>{2}} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\BoolVarAnd,\BoolVarAndTF}
+\begin{function}{\BoolVarAnd,\BoolVarAndT,\BoolVarAndF,\BoolVarAndTF}
\begin{syntax}
\cs{BoolVarAnd} \meta{boolean_1} \meta{boolean_2}
+\cs{BoolVarAndT} \meta{boolean_1} \meta{boolean_2} \Arg{true code}
+\cs{BoolVarAndF} \meta{boolean_1} \meta{boolean_2} \Arg{false code}
\cs{BoolVarAndTF} \meta{boolean_1} \meta{boolean_2} \Arg{true code} \Arg{false code}
\end{syntax}
Implements the \enquote{And} operation between two booleans,
@@ -830,13 +859,15 @@ The \meta{boolean_2} is only evaluated if it is needed to determine the result o
\cs{BoolVarAnd}.
For example
\begin{demohigh}
-\BoolVarAndTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Result{Yes}} {\Result{No}}
+\BoolVarAndTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\BoolVarOr,\BoolVarOrTF}
+\begin{function}{\BoolVarOr,\BoolVarOrT,\BoolVarOrF,\BoolVarOrTF}
\begin{syntax}
\cs{BoolVarOr} \meta{boolean_1} \meta{boolean_2}
+\cs{BoolVarOrT} \meta{boolean_1} \meta{boolean_2} \Arg{true code}
+\cs{BoolVarOrF} \meta{boolean_1} \meta{boolean_2} \Arg{false code}
\cs{BoolVarOrTF} \meta{boolean_1} \meta{boolean_2} \Arg{true code} \Arg{false code}
\end{syntax}
Implements the \enquote{Or} operation between two booleans,
@@ -846,19 +877,121 @@ The \meta{boolean_2} is only evaluated if it is needed to determine the result o
\cs{BoolVarOr}.
For example
\begin{demohigh}
-\BoolVarOrTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Result{Yes}} {\Result{No}}
+\BoolVarOrTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\BoolVarXor,\BoolVarXorTF}
+\begin{function}{\BoolVarXor,\BoolVarXorT,\BoolVarXorF,\BoolVarXorTF}
\begin{syntax}
\cs{BoolVarXor} \meta{boolean_1} \meta{boolean_2}
+\cs{BoolVarXorT} \meta{boolean_1} \meta{boolean_2} \Arg{true code}
+\cs{BoolVarXorF} \meta{boolean_1} \meta{boolean_2} \Arg{false code}
\cs{BoolVarXorTF} \meta{boolean_1} \meta{boolean_2} \Arg{true code} \Arg{false code}
\end{syntax}
Implements an \enquote{exclusive or} operation between two booleans.
For example
\begin{demohigh}
-\BoolVarXorTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Result{Yes}} {\Result{No}}
+\BoolVarXorTF {\IntCompare{3}>{2}} {\IntCompare{3}>{4}} {\Return{Yes}} {\Return{No}}
+\end{demohigh}
+\end{function}
+
+\section{Booleans and Logical Loops}
+
+Loops using either boolean expressions or stored boolean values.
+
+\begin{function}{\BoolDoUntil}
+\begin{syntax}
+\cs{BoolDoUntil} \meta{boolean} \Arg{code}
+\end{syntax}
+Places the \meta{code} in the input stream for \TeX{} to process,
+and then checks the logical value of the \meta{boolean}. If it is
+\texttt{false} then the \meta{code} is inserted into the input
+stream again and the process loops until the \meta{boolean} is
+\texttt{true}.
+\begin{demohigh}
+\IgnoreSpacesOn
+\BoolSetFalse \lTmpaBool
+\IntZero \lTmpaInt
+\ClistClear \lTmpaClist
+\BoolVarDoUntil \lTmpaBool {
+ \IntIncr \lTmpaInt
+ \ClistPutRight \lTmpaClist {\Value\lTmpaInt}
+ \IntCompareT {\lTmpaInt} = {10} {\BoolSetTrue \lTmpaBool}
+}
+\ClistVarJoin \lTmpaClist {:}
+\IgnoreSpacesOff
+\end{demohigh}
+\end{function}
+
+\begin{function}{\BoolDoWhile}
+\begin{syntax}
+\cs{BoolDoWhile} \meta{boolean} \Arg{code}
+\end{syntax}
+Places the \meta{code} in the input stream for \TeX{} to process,
+and then checks the logical value of the \meta{boolean}. If it is
+\texttt{true} then the \meta{code} is inserted into the input
+stream again and the process loops until the \meta{boolean} is
+\texttt{false}.
+\begin{demohigh}
+\IgnoreSpacesOn
+\BoolSetTrue \lTmpaBool
+\IntZero \lTmpaInt
+\ClistClear \lTmpaClist
+\BoolVarDoWhile \lTmpaBool {
+ \IntIncr \lTmpaInt
+ \ClistPutRight \lTmpaClist {\Value\lTmpaInt}
+ \IntCompareT {\lTmpaInt} = {10} {\BoolSetFalse \lTmpaBool}
+}
+\ClistVarJoin \lTmpaClist {:}
+\IgnoreSpacesOff
+\end{demohigh}
+\end{function}
+
+\begin{function}{\BoolUntilDo}
+\begin{syntax}
+\cs{BoolUntilDo} \meta{boolean} \Arg{code}
+\end{syntax}
+This function firsts checks the logical value of the \meta{boolean}.
+If it is \texttt{false} the \meta{code} is placed in the input stream
+and expanded. After the completion of the \meta{code} the truth
+of the \meta{boolean} is re-evaluated. The process then loops
+until the \meta{boolean} is \texttt{true}.
+\begin{demohigh}
+\IgnoreSpacesOn
+\BoolSetFalse \lTmpaBool
+\IntZero \lTmpaInt
+\ClistClear \lTmpaClist
+\BoolVarUntilDo \lTmpaBool {
+ \IntIncr \lTmpaInt
+ \ClistPutRight \lTmpaClist {\Value\lTmpaInt}
+ \IntCompareT {\lTmpaInt} = {10} {\BoolSetTrue \lTmpaBool}
+}
+\ClistVarJoin \lTmpaClist {:}
+\IgnoreSpacesOff
+\end{demohigh}
+\end{function}
+
+\begin{function}{\BoolWhileDo}
+\begin{syntax}
+\cs{BoolWhileDo} \meta{boolean} \Arg{code}
+\end{syntax}
+This function firsts checks the logical value of the \meta{boolean}.
+If it is \texttt{true} the \meta{code} is placed in the input stream
+and expanded. After the completion of the \meta{code} the truth
+of the \meta{boolean} is re-evaluated. The process then loops
+until the \meta{boolean} is \texttt{false}.
+\begin{demohigh}
+\IgnoreSpacesOn
+\BoolSetTrue \lTmpaBool
+\IntZero \lTmpaInt
+\ClistClear \lTmpaClist
+\BoolVarWhileDo \lTmpaBool {
+ \IntIncr \lTmpaInt
+ \ClistPutRight \lTmpaClist {\Value\lTmpaInt}
+ \IntCompareT {\lTmpaInt} = {10} {\BoolSetFalse \lTmpaBool}
+}
+\ClistVarJoin \lTmpaClist {:}
+\IgnoreSpacesOff
\end{demohigh}
\end{function}
@@ -920,7 +1053,7 @@ Constant that is always empty.
%will \emph{not} match the simple text input \verb|-NoValue-|, \emph{i.e.}
%that
%\begin{demohigh}
-%\TlIfEqTF {\TlUse\cNoValueTl} {-NoValue-} {Result{Yes}} {\Result{No}}
+%\TlIfEqTF {\TlUse\cNoValueTl} {-NoValue-} {Result{Yes}} {\Return{No}}
%\end{demohigh}
%The \cs{cNoValueTl} marker is intended for
%use in creating document-level interfaces, where it serves as an indicator
@@ -1478,7 +1611,7 @@ receives the \meta{item} as \verb|#1|. For example,
\TlMapInline {one} {
\TlPutRight \lTmpaTl {[#1]}
}
-\Result{\TlUse\lTmpaTl}
+\Return{\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces [o][n][e].
@@ -1498,7 +1631,7 @@ receives the \meta{item} as \verb|#1|. For example,
\TlVarMapInline \lTmpkTl {
\TlPutRight \lTmpaTl {[#1]}
}
-\Result{\TlUse\lTmpaTl}
+\Return{\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces [o][n][e].
@@ -1538,7 +1671,7 @@ Its value after the loop is the last \meta{item} in the
\TlMapVariable {one} \lTmpiTl {
\TlPutRight \lTmpaTl {\Expand {[\lTmpiTl]}}
}
-\Result{\TlUse\lTmpaTl}
+\Return{\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{demohigh}
\end{function}
@@ -1560,7 +1693,7 @@ or its original value if the \meta{tl var} is blank.
\TlVarMapVariable \lTmpkTl \lTmpiTl {
\TlPutRight \lTmpaTl {\Expand {[\lTmpiTl]}}
}
-\Result{\TlUse\lTmpaTl}
+\Return{\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{demohigh}
\end{function}
@@ -1618,50 +1751,58 @@ or its original value if the \meta{tl var} is blank.
\section{Token List Conditionals}
-\begin{function}{\TlIfExist,\TlIfExistTF}
+\begin{function}{\TlIfExist,\TlIfExistT,\TlIfExistF,\TlIfExistTF}
\begin{syntax}
\cs{TlIfExist} \meta{tl var}
+\cs{TlIfExistT} \meta{tl var} \Arg{true code}
+\cs{TlIfExistF} \meta{tl var} \Arg{false code}
\cs{TlIfExistTF} \meta{tl var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{tl var} is currently defined. This does not
check that the \meta{tl var} really is a token list variable.
\begin{demohigh}
-\TlIfExistTF \lTmpaTl {\Result{Yes}} {\Result{No}}
-\TlIfExistTF \lFooUndefinedTl {\Result{Yes}} {\Result{No}}
+\TlIfExistTF \lTmpaTl {\Return{Yes}} {\Return{No}}
+\TlIfExistTF \lFooUndefinedTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\TlIfEmpty,\TlIfEmptyTF}
+\begin{function}{\TlIfEmpty,\TlIfEmptyT,\TlIfEmptyF,\TlIfEmptyTF}
\begin{syntax}
\cs{TlIfEmpty} \Arg{token list}
+\cs{TlIfEmptyT} \Arg{token list} \Arg{true code}
+\cs{TlIfEmptyF} \Arg{token list} \Arg{false code}
\cs{TlIfEmptyTF} \Arg{token list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token list} is entirely empty
(\emph{i.e.}~contains no tokens at all). For example
\begin{demohigh}
-\TlIfEmptyTF {abc} {\Result{Empty}} {\Result{NonEmpty}}
-\TlIfEmptyTF {} {\Result{Empty}} {\Result{NonEmpty}}
+\TlIfEmptyTF {abc} {\Return{Empty}} {\Return{NonEmpty}}
+\TlIfEmptyTF {} {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\TlVarIfEmpty,\TlVarIfEmptyTF}
+\begin{function}{\TlVarIfEmpty,\TlVarIfEmptyT,\TlVarIfEmptyF,\TlVarIfEmptyTF}
\begin{syntax}
\cs{TlVarIfEmpty} \meta{tl~var}
+\cs{TlVarIfEmptyT} \meta{tl~var} \Arg{true code}
+\cs{TlVarIfEmptyF} \meta{tl~var} \Arg{false code}
\cs{TlVarIfEmptyTF} \meta{tl~var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token list variable} is entirely empty
(\emph{i.e.}~contains no tokens at all). For example
\begin{demohigh}
\TlSet \lTmpaTl {abc}
-\TlVarIfEmptyTF \lTmpaTl {\Result{Empty}} {\Result{NonEmpty}}
+\TlVarIfEmptyTF \lTmpaTl {\Return{Empty}} {\Return{NonEmpty}}
\TlClear \lTmpaTl
-\TlVarIfEmptyTF \lTmpaTl {\Result{Empty}} {\Result{NonEmpty}}
+\TlVarIfEmptyTF \lTmpaTl {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\TlIfBlank}
+\begin{function}{\TlIfBlank,\TlIfBlankT,\TlIfBlankF,\TlIfBlankTF}
\begin{syntax}
\cs{TlIfBlank} \Arg{token list}
+\cs{TlIfBlankT} \Arg{token list} \Arg{true code}
+\cs{TlIfBlankF} \Arg{token list} \Arg{false code}
\cs{TlIfBlankTF} \Arg{token list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token list} consists only of blank spaces
@@ -1670,14 +1811,16 @@ Tests if the \meta{token list} consists only of blank spaces
(explicit tokens with character code $32$ and category code $10$),
and is \texttt{false} otherwise.
\begin{demohigh}
-\TlIfEmptyTF { } {\Result{Yes}} {\Result{No}}
-\TlIfBlankTF { } {\Result{Yes}} {\Result{No}}
+\TlIfEmptyTF { } {\Return{Yes}} {\Return{No}}
+\TlIfBlankTF { } {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\TlIfEq,\TlIfEqTF}
+\begin{function}{\TlIfEq,\TlIfEqT,\TlIfEqF,\TlIfEqTF}
\begin{syntax}
\cs{TlIfEq} \Arg{token list_1} \Arg{token list_2}
+\cs{TlIfEqT} \Arg{token list_1} \Arg{token list_2} \Arg{true code}
+\cs{TlIfEqF} \Arg{token list_1} \Arg{token list_2} \Arg{false code}
\cs{TlIfEqTF} \Arg{token list_1} \Arg{token list_2} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if \meta{token list_1} and \meta{token list_2} contain the
@@ -1685,21 +1828,23 @@ same list of tokens, both in respect of character codes and category
codes. See \cs{StrIfEq} if category codes are not important.
For example
\begin{demohigh}
-\TlIfEqTF {abc} {abc} {\Result{Yes}} {\Result{No}}
-\TlIfEqTF {abc} {xyz} {\Result{Yes}} {\Result{No}}
+\TlIfEqTF {abc} {abc} {\Return{Yes}} {\Return{No}}
+\TlIfEqTF {abc} {xyz} {\Return{Yes}} {\Return{No}}
\end{demohigh}
%\begin{demohigh}
%\TlSet\lTmpaTl{abc}
%\TlSet\lTmpbTl{abc}
%\TlSet\lTmpcTl{xyz}
-%\TlIfEqTF{\TlUse\lTmpaTl}{\TlUse\lTmpbTl}{\Result{Yes}}{\Result{No}}
-%\TlIfEqTF{\TlUse\lTmpaTl}{\TlUse\lTmpcTl}{\Result{Yes}}{\Result{No}}
+%\TlIfEqTF{\TlUse\lTmpaTl}{\TlUse\lTmpbTl}{\Return{Yes}}{\Return{No}}
+%\TlIfEqTF{\TlUse\lTmpaTl}{\TlUse\lTmpcTl}{\Return{Yes}}{\Return{No}}
%\end{demohigh}
\end{function}
-\begin{function}{\TlVarIfEq,\TlVarIfEqTF}
+\begin{function}{\TlVarIfEq,\TlVarIfEqT,\TlVarIfEqF,\TlVarIfEqTF}
\begin{syntax}
\cs{TlVarIfEq} \meta{tl var_1} \meta{tl var_2}
+\cs{TlVarIfEqT} \meta{tl var_1} \meta{tl var_2} \Arg{true code}
+\cs{TlVarIfEqF} \meta{tl var_1} \meta{tl var_2} \Arg{false code}
\cs{TlVarIfEqTF} \meta{tl var_1} \meta{tl var_2} \Arg{true code} \Arg{false code}
\end{syntax}
Compares the content of two \meta{token list variables} and
@@ -1710,15 +1855,17 @@ contain and the category codes of those characters). For example
\TlSet \lTmpaTl {abc}
\TlSet \lTmpbTl {abc}
\TlSet \lTmpcTl {xyz}
-\TlVarIfEqTF \lTmpaTl \lTmpbTl {\Result{Yes}} {\Result{No}}
-\TlVarIfEqTF \lTmpaTl \lTmpcTl {\Result{Yes}} {\Result{No}}
+\TlVarIfEqTF \lTmpaTl \lTmpbTl {\Return{Yes}} {\Return{No}}
+\TlVarIfEqTF \lTmpaTl \lTmpcTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
See also \cs{StrVarIfEq} for a comparison that ignores category codes.
\end{function}
-\begin{function}{\TlIfIn,\TlIfInTF}
+\begin{function}{\TlIfIn,\TlIfInT,\TlIfInF,\TlIfInTF}
\begin{syntax}
\cs{TlIfIn} \Arg{token list_1} \Arg{token list_2}
+\cs{TlIfInT} \Arg{token list_1} \Arg{token list_2} \Arg{true code}
+\cs{TlIfInF} \Arg{token list_1} \Arg{token list_2} \Arg{false code}
\cs{TlIfInTF} \Arg{token list_1} \Arg{token list_2} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if \meta{token list_2} is found inside \meta{token list_1}.
@@ -1727,14 +1874,16 @@ The \meta{token list_2} cannot contain the tokens \verb|{|, \verb|}| or \verb|#|
(begin-group) or $2$ (end-group), and tokens with category code $6$).
The search does \emph{not} enter brace (category code $1$/$2$) groups.
\begin{demohigh}
-\TlIfInTF {hello world} {o} {\Result{Yes}} {\Result{No}}
-\TlIfInTF {hello world} {a} {\Result{Yes}} {\Result{No}}
+\TlIfInTF {hello world} {o} {\Return{Yes}} {\Return{No}}
+\TlIfInTF {hello world} {a} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\TlVarIfIn,\TlVarIfInTF}
+\begin{function}{\TlVarIfIn,\TlVarIfInT,\TlVarIfInF,\TlVarIfInTF}
\begin{syntax}
\cs{TlVarIfIn} \meta{tl var} \Arg{token list}
+\cs{TlVarIfInT} \meta{tl var} \Arg{token list} \Arg{true code}
+\cs{TlVarIfInF} \meta{tl var} \Arg{token list} \Arg{false code}
\cs{TlVarIfInTF} \meta{tl var} \Arg{token list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token list} is found in the content of the
@@ -1744,14 +1893,16 @@ the tokens \verb|{|, \verb|}| or \verb|#|
(begin-group) or $2$ (end-group), and tokens with category code $6$).
\begin{demohigh}
\TlSet \lTmpaTl {hello world}
-\TlVarIfInTF \lTmpaTl {o} {\Result{Yes}} {\Result{No}}
-\TlVarIfInTF \lTmpaTl {a} {\Result{Yes}} {\Result{No}}
+\TlVarIfInTF \lTmpaTl {o} {\Return{Yes}} {\Return{No}}
+\TlVarIfInTF \lTmpaTl {a} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\TlIfSingle,\TlIfSingleTF}
+\begin{function}{\TlIfSingle,\TlIfSingleT,\TlIfSingleF,\TlIfSingleTF}
\begin{syntax}
\cs{TlIfSingle} \Arg{token list}
+\cs{TlIfSingleT} \Arg{token list} \Arg{true code}
+\cs{TlIfSingleF} \Arg{token list} \Arg{false code}
\cs{TlIfSingleTF} \Arg{token list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token list} has exactly one \meta{item}, \emph{i.e.} is
@@ -1760,14 +1911,16 @@ begin-group character) or a single brace group, surrounded by
optional spaces on both sides. In other words, such a token list has
token count $1$ according to \cs{TlCount}.
\begin{demohigh}
-\TlIfSingleTF {a} {\Result{Yes}} {\Result{No}}
-\TlIfSingleTF {abc} {\Result{Yes}} {\Result{No}}
+\TlIfSingleTF {a} {\Return{Yes}} {\Return{No}}
+\TlIfSingleTF {abc} {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\TlVarIfSingle,\TlVarIfSingleTF}
+\begin{function}{\TlVarIfSingle,\TlVarIfSingleT,\TlVarIfSingleF,\TlVarIfSingleTF}
\begin{syntax}
\cs{TlVarIfSingle} \meta{tl var}
+\cs{TlVarIfSingleT} \meta{tl var} \Arg{true code}
+\cs{TlVarIfSingleF} \meta{tl var} \Arg{false code}
\cs{TlVarIfSingleTF} \meta{tl var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the content of the \meta{tl var} consists of a single \meta{item},
@@ -1777,9 +1930,9 @@ surrounded by optional spaces on both sides. In other words, such a
token list has token count $1$ according to \cs{TlVarCount}.
\begin{demohigh}
\TlSet \lTmpaTl {a}
-\TlVarIfSingleTF \lTmpaTl {\Result{Yes}} {\Result{No}}
+\TlVarIfSingleTF \lTmpaTl {\Return{Yes}} {\Return{No}}
\TlSet \lTmpaTl {abc}
-\TlVarIfSingleTF \lTmpaTl {\Result{Yes}} {\Result{No}}
+\TlVarIfSingleTF \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -1808,9 +1961,9 @@ does nothing if there is no match.
\TlSet \lTmpcTl {c}
\TlSet \lTmpkTl {b}
\TlVarCase \lTmpkTl {
- \lTmpaTl {\Result {First}}
- \lTmpbTl {\Result {Second}}
- \lTmpcTl {\Result {Third}}
+ \lTmpaTl {\Return {First}}
+ \lTmpbTl {\Return {Second}}
+ \lTmpcTl {\Return {Third}}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -1845,7 +1998,7 @@ input stream (after the code for the appropriate case).
\lTmpbTl {\IntSet \lTmpkInt {2}}
\lTmpcTl {\IntSet \lTmpkInt {3}}
}{
- \Result {\IntUse \lTmpkInt}
+ \Return {\IntUse \lTmpkInt}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -1875,11 +2028,11 @@ is inserted into the input stream (after the code for the appropriate case).
\TlSet \lTmpcTl {c}
\TlSet \lTmpkTl {b}
\TlVarCaseF \lTmpkTl{
- \lTmpaTl {\Result {First}}
- \lTmpbTl {\Result {Second}}
- \lTmpcTl {\Result {Third}}
+ \lTmpaTl {\Return {First}}
+ \lTmpbTl {\Return {Second}}
+ \lTmpcTl {\Return {Third}}
}{
- \Result {No~Match!}
+ \Return {No~Match!}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -1917,9 +2070,9 @@ which does nothing if there is no match, is also available.
\lTmpbTl {\IntSet \lTmpkInt {2}}
\lTmpcTl {\IntSet \lTmpkInt {3}}
}{
- \Result {\IntUse \lTmpkInt}
+ \Return {\IntUse \lTmpkInt}
}{
- \Result {0}
+ \Return {0}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -2376,7 +2529,7 @@ For example,
\StrMapInline {one} {
\StrPutRight \lTmpaStr {[#1]}
}
-\Result{\StrUse\lTmpaStr}
+\Return{\StrUse\lTmpaStr}
\IgnoreSpacesOff
\end{codehigh}
produces [o][n][e].
@@ -2413,7 +2566,7 @@ the (string or token list) \meta{variable} and applies the
\StrMapVariable {one} \lTmpiStr {
\StrPutRight \lTmpaStr {\Expand {[\lTmpiStr]}}
}
-\Result{\StrUse\lTmpaStr}
+\Return{\StrUse\lTmpaStr}
\IgnoreSpacesOff
\end{demohigh}
\end{function}
@@ -2471,37 +2624,43 @@ the (string or token list) \meta{variable} and applies the
\section{String Conditionals}
-\begin{function}{\StrIfExist,\StrIfExistTF}
+\begin{function}{\StrIfExist,\StrIfExistT,\StrIfExistF,\StrIfExistTF}
\begin{syntax}
\cs{StrIfExist} \meta{str var}
+\cs{StrIfExistT} \meta{str var} \Arg{true code}
+\cs{StrIfExistF} \meta{str var} \Arg{false code}
\cs{StrIfExistTF} \meta{str var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{str var} is currently defined. This does not
check that the \meta{str var} really is a string.
\begin{demohigh}
-\StrIfExistTF\lTmpaStr{\Result{Yes}}{\Result{No}}
-\StrIfExistTF\lFooUndefinedStr{\Result{Yes}}{\Result{No}}
+\StrIfExistTF \lTmpaStr {\Return{Yes}} {\Return{No}}
+\StrIfExistTF \lFooUndefinedStr {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\StrVarIfEmpty,\StrVarIfEmptyTF}
+\begin{function}{\StrVarIfEmpty,\StrVarIfEmptyT,\StrVarIfEmptyF,\StrVarIfEmptyTF}
\begin{syntax}
\cs{StrVarIfEmpty} \meta{str var}
+\cs{StrVarIfEmptyT} \meta{str var} \Arg{true code}
+\cs{StrVarIfEmptyF} \meta{str var} \Arg{false code}
\cs{StrVarIfEmptyTF} \meta{str var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{string variable} is entirely empty
(\emph{i.e.} contains no characters at all).
\begin{demohigh}
\StrSet \lTmpaStr {abc}
-\StrVarIfEmptyTF \lTmpaStr {\Result{Empty}} {\Result{NonEmpty}}
+\StrVarIfEmptyTF \lTmpaStr {\Return{Empty}} {\Return{NonEmpty}}
\StrClear \lTmpaStr
-\StrVarIfEmptyTF \lTmpaStr {\Result{Empty}} {\Result{NonEmpty}}
+\StrVarIfEmptyTF \lTmpaStr {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\StrIfEq,\StrIfEqTF}
+\begin{function}{\StrIfEq,\StrIfEqT,\StrIfEqF,\StrIfEqTF}
\begin{syntax}
\cs{StrIfEq} \Arg{tl_1} \Arg{tl_2}
+\cs{StrIfEqT} \Arg{tl_1} \Arg{tl_2} \Arg{true code}
+\cs{StrIfEqF} \Arg{tl_1} \Arg{tl_2} \Arg{false code}
\cs{StrIfEqTF} \Arg{tl_1} \Arg{tl_2} \Arg{true code} \Arg{false code}
\end{syntax}
Compares the two \meta{token lists} on a character by character
@@ -2517,23 +2676,25 @@ See \cs{TlIfEq} to compare
tokens (including their category codes) rather than characters.
For example
\begin{demohigh}
-\StrIfEqTF {abc} {abc} {\Result{Yes}} {\Result{No}}
-\StrIfEqTF {abc} {xyz} {\Result{Yes}} {\Result{No}}
+\StrIfEqTF {abc} {abc} {\Return{Yes}} {\Return{No}}
+\StrIfEqTF {abc} {xyz} {\Return{Yes}} {\Return{No}}
\end{demohigh}
%\begin{demohigh}
%\StrSet\lTmpaStr{abc}
%\StrSet\lTmpbStr{abc}
%\StrSet\lTmpcStr{xyz}
-%\StrIfEqTF{\lTmpaStr}{\lTmpbStr}{\Result{Yes}}{\Result{No}}
-%\StrIfEqTF{\lTmpaStr}{\lTmpcStr}{\Result{Yes}}{\Result{No}}
-%\StrIfEqTF{\StrUse\lTmpaStr}{\StrUse\lTmpbStr}{\Result{Yes}}{\Result{No}}
-%\StrIfEqTF{\StrUse\lTmpaStr}{\StrUse\lTmpcStr}{\Result{Yes}}{\Result{No}}
+%\StrIfEqTF{\lTmpaStr}{\lTmpbStr}{\Return{Yes}}{\Return{No}}
+%\StrIfEqTF{\lTmpaStr}{\lTmpcStr}{\Return{Yes}}{\Return{No}}
+%\StrIfEqTF{\StrUse\lTmpaStr}{\StrUse\lTmpbStr}{\Return{Yes}}{\Return{No}}
+%\StrIfEqTF{\StrUse\lTmpaStr}{\StrUse\lTmpcStr}{\Return{Yes}}{\Return{No}}
%\end{demohigh}
\end{function}
-\begin{function}{\StrVarIfEq,\StrVarIfEqTF}
+\begin{function}{\StrVarIfEq,\StrVarIfEqT,\StrVarIfEqF,\StrVarIfEqTF}
\begin{syntax}
\cs{StrVarIfEq} \meta{str var_1} \meta{str var_2}
+\cs{StrVarIfEqT} \meta{str var_1} \meta{str var_2} \Arg{true code}
+\cs{StrVarIfEqF} \meta{str var_1} \meta{str var_2} \Arg{false code}
\cs{StrVarIfEqTF} \meta{str var_1} \meta{str var_2} \Arg{true code} \Arg{false code}
\end{syntax}
Compares the content of two \meta{str variables} and
@@ -2544,41 +2705,47 @@ in the same order. See \cs{TlVarIfEq} to compare tokens
\StrSet \lTmpaStr {abc}
\StrSet \lTmpbStr {abc}
\StrSet \lTmpcStr {xyz}
-\StrVarIfEqTF \lTmpaStr \lTmpbStr {\Result{Yes}} {\Result{No}}
-\StrVarIfEqTF \lTmpaStr \lTmpcStr {\Result{Yes}} {\Result{No}}
+\StrVarIfEqTF \lTmpaStr \lTmpbStr {\Return{Yes}} {\Return{No}}
+\StrVarIfEqTF \lTmpaStr \lTmpcStr {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\StrIfIn,\StrIfInTF}
+\begin{function}{\StrIfIn,\StrIfInT,\StrIfInF,\StrIfInTF}
\begin{syntax}
-\cs{StrIfInTF} \Arg{tl_1} \Arg{tl_2}
+\cs{StrIfIn} \Arg{tl_1} \Arg{tl_2}
+\cs{StrIfInT} \Arg{tl_1} \Arg{tl_2} \Arg{true code}
+\cs{StrIfInF} \Arg{tl_1} \Arg{tl_2} \Arg{false code}
\cs{StrIfInTF} \Arg{tl_1} \Arg{tl_2} \Arg{true code} \Arg{false code}
\end{syntax}
Converts both \meta{token lists} to \meta{strings} and
tests whether \meta{string_2} is found inside \meta{string_1}.
\begin{demohigh}
-\StrIfInTF {hello world} {o} {\Result{Yes}}{\Result{No}}
-\StrIfInTF {hello world} {a} {\Result{Yes}}{\Result{No}}
+\StrIfInTF {hello world} {o} {\Return{Yes}}{\Return{No}}
+\StrIfInTF {hello world} {a} {\Return{Yes}}{\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\StrVarIfIn,\StrVarIfInTF}
+\begin{function}{\StrVarIfIn,\StrVarIfInT,\StrVarIfInF,\StrVarIfInTF}
\begin{syntax}
-\cs{StrVarIfInTF} \meta{str var} \Arg{token list}
+\cs{StrVarIfIn} \meta{str var} \Arg{token list}
+\cs{StrVarIfInT} \meta{str var} \Arg{token list} \Arg{true code}
+\cs{StrVarIfInF} \meta{str var} \Arg{token list} \Arg{false code}
\cs{StrVarIfInTF} \meta{str var} \Arg{token list} \Arg{true code} \Arg{false code}
\end{syntax}
Converts the \meta{token list} to a \meta{string} and
tests if that \meta{string} is found in the content of the \meta{str var}.
\begin{demohigh}
\StrSet \lTmpaStr {hello world}
-\StrVarIfInTF \lTmpaStr {o} {\Result{Yes}}{\Result{No}}
-\StrVarIfInTF \lTmpaStr {a} {\Result{Yes}}{\Result{No}}
+\StrVarIfInTF \lTmpaStr {o} {\Return{Yes}}{\Return{No}}
+\StrVarIfInTF \lTmpaStr {a} {\Return{Yes}}{\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\StrCompare,\StrCompareTF}
+\begin{function}{\StrCompare,\StrCompareT,\StrCompareF,\StrCompareTF}
\begin{syntax}
\cs{StrCompare} \Arg{tl_1} \meta{relation} \Arg{tl_2}
+\cs{StrCompareT} \Arg{tl_1} \meta{relation} \Arg{tl_2} \Arg{true code}
+\cs{StrCompareF} \Arg{tl_1} \meta{relation} \Arg{tl_2} \Arg{false code}
\cs{StrCompareTF} \Arg{tl_1} \meta{relation} \Arg{tl_2} \Arg{true code} \Arg{false code}
\end{syntax}
Compares the two \meta{token lists} on a character by character
@@ -2593,8 +2760,8 @@ order according to the character codes of the characters. The
\end{itemize}
For example:
\begin{demohigh}
-\StrCompareTF {ab} < {abc} {\Result{Yes}} {\Result{No}}
-\StrCompareTF {ab} < {aa} {\Result{Yes}} {\Result{No}}
+\StrCompareTF {ab} < {abc} {\Return{Yes}} {\Return{No}}
+\StrCompareTF {ab} < {aa} {\Return{Yes}} {\Return{No}}
\end{demohigh}
%\begin{texnote}
%This is a wrapper around the \TeX{} primitive
@@ -2628,9 +2795,9 @@ input stream and other cases are discarded.
\begin{demohigh}
\IgnoreSpacesOn
\StrCase {bbb} {
- {aaa} {\Result{First}}
- {bbb} {\Result{Second}}
- {ccb} {\Result{Third}}
+ {aaa} {\Return{First}}
+ {bbb} {\Return{Second}}
+ {ccb} {\Return{Third}}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -2661,7 +2828,7 @@ input stream (after the code for the appropriate case).
{bbb} {\TlSet\lTmpkTl{Second}}
{ccb} {\TlSet\lTmpkTl{Third}}
}{
- \Result{\TlUse\lTmpkTl}
+ \Return{\TlUse\lTmpkTl}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -2687,11 +2854,11 @@ match then the \meta{false code} is inserted.
\begin{demohigh}
\IgnoreSpacesOn
\StrCaseF {bbb} {
- {aaa} {\Result{First}}
- {bbb} {\Result{Second}}
- {ccb} {\Result{Third}}
+ {aaa} {\Return{First}}
+ {bbb} {\Return{Second}}
+ {ccb} {\Return{Third}}
}{
- \Result{No~Match!}
+ \Return{No~Match!}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -2724,9 +2891,9 @@ match then the \meta{false code} is inserted.
{bbb} {\TlSet\lTmpkTl{Second}}
{ccb} {\TlSet\lTmpkTl{Third}}
}{
- \Result{\TlUse\lTmpkTl}
+ \Return{\TlUse\lTmpkTl}
}{
- \Result{No~Match!}
+ \Return{No~Match!}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -3102,7 +3269,7 @@ For example
\IntStepInline {1} {3} {30} {
\TlPutRight \lTmpaTl {[#1]}
}
-\Result {\Value\lTmpaTl}
+\Return {\Value\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces [1][4][7][10][13][16][19][22][25][28].
@@ -3127,25 +3294,29 @@ the \meta{code} should make use of the \meta{tl~var}.
% \TlPutRight\lTmpaTl{\Value\lTmpiTl}
% \TlPutRight\lTmpaTl{~}
%}
-%\Result{\Value\lTmpaTl}
+%\Return{\Value\lTmpaTl}
%\IgnoreSpacesOff
%\end{demohigh}
\end{function}
\section{Integer Conditionals}
-\begin{function}{\IntIfExist, \IntIfExistTF}
+\begin{function}{\IntIfExist,\IntIfExistT,\IntIfExistF,\IntIfExistTF}
\begin{syntax}
\cs{IntIfExist} \meta{integer}
+\cs{IntIfExistT} \meta{integer} \Arg{true code}
+\cs{IntIfExistF} \meta{integer} \Arg{false code}
\cs{IntIfExistTF} \meta{integer} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{integer} is currently defined. This does not
check that the \meta{integer} really is an integer variable.
\end{function}
-\begin{function}{\IntIfOdd,\IntIfOddTF}
+\begin{function}{\IntIfOdd,\IntIfOddT,\IntIfOddF,\IntIfOddTF}
\begin{syntax}
\cs{IntIfOdd} \Arg{integer expression}
+\cs{IntIfOddT} \Arg{integer expression} \Arg{true code}
+\cs{IntIfOddF} \Arg{integer expression} \Arg{false code}
\cs{IntIfOddTF} \Arg{integer expression} \Arg{true code} \Arg{false code}
\end{syntax}
This function first evaluates the \meta{integer expression}
@@ -3153,9 +3324,11 @@ as described for \cs{IntEval}.
It then evaluates if this is odd or even, as appropriate.
\end{function}
-\begin{function}{\IntIfEven,\IntIfEvenTF}
+\begin{function}{\IntIfEven,\IntIfEvenT,\IntIfEvenF,\IntIfEvenTF}
\begin{syntax}
\cs{IntIfEven} \Arg{integer expression}
+\cs{IntIfEvenT} \Arg{integer expression} \Arg{true code}
+\cs{IntIfEvenF} \Arg{integer expression} \Arg{false code}
\cs{IntIfEvenTF} \Arg{integer expression} \Arg{true code} \Arg{false code}
\end{syntax}
This function first evaluates the \meta{integer expression}
@@ -3163,9 +3336,11 @@ as described for \cs{IntEval}.
It then evaluates if this is even or odd, as appropriate.
\end{function}
-\begin{function}{\IntCompare,\IntCompareTF}
+\begin{function}{\IntCompare,\IntCompareT,\IntCompareF,\IntCompareTF}
\begin{syntax}
\cs{IntCompare} \Arg{intexpr_1} \meta{relation} \Arg{intexpr_2}
+\cs{IntCompareT} \Arg{intexpr_1} \meta{relation} \Arg{intexpr_2} \Arg{true code}
+\cs{IntCompareF} \Arg{intexpr_1} \meta{relation} \Arg{intexpr_2} \Arg{false code}
\cs{IntCompareTF} \Arg{intexpr_1} \meta{relation} \Arg{intexpr_2} \Arg{true code} \Arg{false code}
\end{syntax}
This function first evaluates each of the \meta{integer expressions}
@@ -3178,8 +3353,8 @@ Less than & \texttt{<} \\
\end{tabular}\par}
For example
\begin{demohigh}
-\IntCompareTF {2} > {1} {\Result{Greater}} {\Result{Less}}
-\IntCompareTF {2} > {3} {\Result{Greater}} {\Result{Less}}
+\IntCompareTF {2} > {1} {\Return{Greater}} {\Return{Less}}
+\IntCompareTF {2} > {3} {\Return{Greater}} {\Return{Less}}
\end{demohigh}
\end{function}
@@ -3637,7 +3812,7 @@ For example
\FpStepInline {1} {0.1} {1.5} {
\TlPutRight \lTmpaTl {[#1]}
}
-\Result {\Value\lTmpaTl}
+\Return {\Value\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces [1][1.1][1.2][1.3][1.4][1.5].
@@ -3663,37 +3838,41 @@ the \meta{code} should make use of the \meta{tl var}.
% \TlPutRight\lTmpaTl{\Value\lTmpiTl}
% \TlPutRight\lTmpaTl{~}
%}
-%\Result{\Value\lTmpaTl}
+%\Return{\Value\lTmpaTl}
%\IgnoreSpacesOff
%\end{demohigh}
\end{function}
\section{Float Point Conditionals}
-\begin{function}{\FpIfExist,\FpIfExistTF}
+\begin{function}{\FpIfExist,\FpIfExistT,\FpIfExistF,\FpIfExistTF}
\begin{syntax}
\cs{FpIfExist} \meta{fp var}
+\cs{FpIfExistT} \meta{fp var} \Arg{true code}
+\cs{FpIfExistF} \meta{fp var} \Arg{false code}
\cs{FpIfExistTF} \meta{fp var} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{fp var} is currently defined. This does not
check that the \meta{fp var} really is a floating point variable.
For example
\begin{demohigh}
-\FpIfExistTF \lTmpaFp {\Result{Yes}} {\Result{No}}
-\FpIfExistTF \lMyUndefinedFp {\Result{Yes}} {\Result{No}}
+\FpIfExistTF \lTmpaFp {\Return{Yes}} {\Return{No}}
+\FpIfExistTF \lMyUndefinedFp {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\FpCompare,\FpCompareTF}
+\begin{function}{\FpCompare,\FpCompareT,\FpCompareF,\FpCompareTF}
\begin{syntax}
\cs{FpCompare} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2}
+\cs{FpCompareT} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{true code}
+\cs{FpCompareF} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{false code}
\cs{FpCompareTF} \Arg{fpexpr_1} \meta{relation} \Arg{fpexpr_2} \Arg{true code} \Arg{false code}
\end{syntax}
Compares the \meta{fpexpr_1} and the \meta{fpexpr_2}, and returns
\texttt{true} if the \meta{relation} is obeyed. For example
\begin{demohigh}
-\FpCompareTF {1} > {0.9999} {\Result{Greater}} {\Result{Less}}
-\FpCompareTF {1} > {1.0001} {\Result{Greater}} {\Result{Less}}
+\FpCompareTF {1} > {0.9999} {\Return{Greater}} {\Return{Less}}
+\FpCompareTF {1} > {1.0001} {\Return{Greater}} {\Return{Less}}
\end{demohigh}
Two floating points
$x$ and $y$ may obey four mutually exclusive relations:
@@ -3704,7 +3883,7 @@ any value, even another \nan{}, hence $x=x$ is not true for
a \nan{}. To test if a value is \nan{}, compare it to an arbitrary
number with the \enquote{not ordered} relation.\par
%\begin{demohigh}
-%\FpCompareTF{0/0}?{0}{\Result{Is~a~Nan}}{\Result{Isn't~a~NaN}}
+%\FpCompareTF{0/0}?{0}{\Return{Is~a~Nan}}{\Return{Isn't~a~NaN}}
%\end{demohigh}
Tuples are equal if they have the same number of items and items
compare equal (in particular there must be no \nan{}).
@@ -4029,7 +4208,7 @@ For example
\DimStepInline {1pt} {0.1pt} {1.5pt} {
\TlPutRight \lTmpaTl {[#1]}
}
-\Result {\Value\lTmpaTl}
+\Return {\Value\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces [1.0pt][1.1pt][1.20001pt][1.30002pt][1.40002pt].
@@ -4054,30 +4233,34 @@ the \meta{code} should make use of the \meta{tl var}.
% \TlPutRight\lTmpaTl{\Value\lTmpiTl}
% \TlPutRight\lTmpaTl{~}
%}
-%\Result{\Value\lTmpaTl}
+%\Return{\Value\lTmpaTl}
%\IgnoreSpacesOff
%\end{demohigh}
\end{function}
\section{Dimension Conditionals}
-\begin{function}{\DimIfExist,\DimIfExistTF}
+\begin{function}{\DimIfExist,\DimIfExistT,\DimIfExistF,\DimIfExistTF}
\begin{syntax}
\cs{DimIfExist} \meta{dimension}
+\cs{DimIfExistT} \meta{dimension} \Arg{true code}
+\cs{DimIfExistF} \meta{dimension} \Arg{false code}
\cs{DimIfExistTF} \meta{dimension} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{dimension} is currently defined. This does
not check that the \meta{dimension} really is a dimension variable.
For example
\begin{demohigh}
-\DimIfExistTF \lTmpaDim {\Result{Yes}} {\Result{No}}
-\DimIfExistTF \lFooUndefinedDim {\Result{Yes}} {\Result{No}}
+\DimIfExistTF \lTmpaDim {\Return{Yes}} {\Return{No}}
+\DimIfExistTF \lFooUndefinedDim {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\DimCompare,\DimCompareTF}
+\begin{function}{\DimCompare,\DimCompareT,\DimCompareF,\DimCompareTF}
\begin{syntax}
\cs{DimCompare} \Arg{dimexpr_1} \meta{relation} \Arg{dimexpr_2}
+\cs{DimCompareT} \Arg{dimexpr_1} \meta{relation} \Arg{dimexpr_2} \Arg{true code}
+\cs{DimCompareF} \Arg{dimexpr_1} \meta{relation} \Arg{dimexpr_2} \Arg{false code}
\cs{DimCompareTF} \Arg{dimexpr_1} \meta{relation} \Arg{dimexpr_2} \Arg{true code} \Arg{false code}
\end{syntax}
This function first evaluates each of the \meta{dimension expressions}
@@ -4091,8 +4274,8 @@ Less than & \verb|<| \\
\end{tabular}\par}
For example
\begin{demohigh}
-\DimCompareTF {1pt} > {0.9999pt} {\Result{Greater}} {\Result{Less}}
-\DimCompareTF {1pt} > {1.0001pt} {\Result{Greater}} {\Result{Less}}
+\DimCompareTF {1pt} > {0.9999pt} {\Return{Greater}} {\Return{Less}}
+\DimCompareTF {1pt} > {1.0001pt} {\Return{Greater}} {\Return{Less}}
\end{demohigh}
\end{function}
@@ -4157,11 +4340,11 @@ For example
\IgnoreSpacesOn
\DimSet \lTmpaDim {5pt}
\DimCaseF {2\lTmpaDim} {
- {5pt} {\Result{Small}}
- {4pt+6pt} {\Result{Medium}}
- {-10pt} {\Result{Negative}}
+ {5pt} {\Return{Small}}
+ {4pt+6pt} {\Return{Medium}}
+ {-10pt} {\Return{Negative}}
}{
- \Result {No Match}
+ \Return {No Match}
}
\IgnoreSpacesOff
\end{demohigh}
@@ -4192,13 +4375,13 @@ match then the \meta{false code} is inserted.
%\IgnoreSpacesOn
%\DimSet\lTmpaDim{5pt}
%\DimCaseTF{2\lTmpaDim}{
-% {5pt} {\Result{Small}}
-% {4pt+6pt} {\Result{Medium}}
-% {-10pt} {\Result{Negative}}
+% {5pt} {\Return{Small}}
+% {4pt+6pt} {\Return{Medium}}
+% {-10pt} {\Return{Negative}}
%}{
-% \Result{[Some Match]}
+% \Return{[Some Match]}
%}{
-% \Result{[No Match]}
+% \Return{[No Match]}
%}
%\IgnoreSpacesOff
%\end{demohigh}
@@ -4697,7 +4880,7 @@ it from the \meta{comma list}.
The \meta{token list variable} is assigned locally.
\begin{demohigh}
\ClistSet \lTmpaClist {two,three,four}
-\ClistGetTF \lTmpaClist \lTmpaTl {\Result{Yes}} {\Result{No}}
+\ClistGetTF \lTmpaClist \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -4733,7 +4916,7 @@ the item from the \meta{comma list}.
The \meta{token list variable} is assigned locally.
\begin{demohigh}
\ClistSet \lTmpaClist {two,three,four}
-\ClistPopTF \lTmpaClist \lTmpaTl {\Result{Yes}} {\Result{No}}
+\ClistPopTF \lTmpaClist \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -4801,7 +4984,7 @@ For example
\ClistMapInline {one,two,three} {
\TlPutRight \lTmpaTl {(#1)}
}
-\Result {\TlUse\lTmpaTl}
+\Return {\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces (one)(two)(three).
@@ -4897,22 +5080,26 @@ list}, or its original value if there were no \meta{item}. The
\section{Comma List Conditionals}
-\begin{function}{\ClistIfExist,\ClistIfExistTF}
+\begin{function}{\ClistIfExist,\ClistIfExistT,\ClistIfExistF,\ClistIfExistTF}
\begin{syntax}
\cs{ClistIfExist} \meta{comma list}
+\cs{ClistIfExistT} \meta{comma list} \Arg{true code}
+\cs{ClistIfExistF} \meta{comma list} \Arg{false code}
\cs{ClistIfExistTF} \meta{comma list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{comma list} is currently defined. This does
not check that the \meta{comma list} really is a comma list.
\begin{demohigh}
-\ClistIfExistTF \lTmpaClist {\Result{Yes}} {\Result{No}}
-\ClistIfExistTF \lFooUndefinedClist {\Result{Yes}} {\Result{No}}
+\ClistIfExistTF \lTmpaClist {\Return{Yes}} {\Return{No}}
+\ClistIfExistTF \lFooUndefinedClist {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\ClistIfEmpty,\ClistIfEmptyTF}
+\begin{function}{\ClistIfEmpty,\ClistIfEmptyT,\ClistIfEmptyF,\ClistIfEmptyTF}
\begin{syntax}
\cs{ClistIfEmpty} \Arg{comma list}
+\cs{ClistIfEmptyT} \Arg{comma list} \Arg{true code}
+\cs{ClistIfEmptyF} \Arg{comma list} \Arg{false code}
\cs{ClistIfEmptyTF} \Arg{comma list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{comma list} is empty (containing no items).
@@ -4922,36 +5109,40 @@ outer braces) is empty, while \verb|{ ,{},}| (without outer braces)
contains one element, which happens to be empty: the comma-list
is not empty.
\begin{demohigh}
-\ClistIfEmptyTF {one,two} {\Result{Empty}} {\Result{NonEmpty}}
-\ClistIfEmptyTF { , } {\Result{Empty}} {\Result{NonEmpty}}
+\ClistIfEmptyTF {one,two} {\Return{Empty}} {\Return{NonEmpty}}
+\ClistIfEmptyTF { , } {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\ClistVarIfEmpty,\ClistVarIfEmptyTF}
+\begin{function}{\ClistVarIfEmpty,\ClistVarIfEmptyT,\ClistVarIfEmptyF,\ClistVarIfEmptyTF}
\begin{syntax}
\cs{ClistVarIfEmpty} \meta{comma list}
+\cs{ClistVarIfEmptyT} \meta{comma list} \Arg{true code}
+\cs{ClistVarIfEmptyF} \meta{comma list} \Arg{false code}
\cs{ClistVarIfEmptyTF} \meta{comma list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{comma list} is empty (containing no items).
\begin{demohigh}
\ClistSet \lTmpaClist {one,two}
-\ClistVarIfEmptyTF \lTmpaClist {\Result{Empty}} {\Result{NonEmpty}}
+\ClistVarIfEmptyTF \lTmpaClist {\Return{Empty}} {\Return{NonEmpty}}
\ClistClear \lTmpaClist
-\ClistVarIfEmptyTF \lTmpaClist {\Result{Empty}} {\Result{NonEmpty}}
+\ClistVarIfEmptyTF \lTmpaClist {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\ClistIfIn,\ClistIfInTF}
+\begin{function}{\ClistIfIn,\ClistIfInT,\ClistIfInF,\ClistIfInTF}
\begin{syntax}
\cs{ClistIfIn} \Arg{comma list} \Arg{item}
+\cs{ClistIfInT} \Arg{comma list} \Arg{item} \Arg{true code}
+\cs{ClistIfInF} \Arg{comma list} \Arg{item} \Arg{false code}
\cs{ClistIfInTF} \Arg{comma list} \Arg{item} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{item} is present in the \meta{comma list}.
In the case of an \texttt{n}-type \meta{comma list}, the usual rules
of space trimming and brace stripping apply. For example
\begin{demohigh}
-\ClistIfInTF { a , {b} , {b} , c } {b} {\Result{Yes}} {\Result{No}}
-\ClistIfInTF { a , {b} , {b} , c } {d} {\Result{Yes}} {\Result{No}}
+\ClistIfInTF { a , {b} , {b} , c } {b} {\Return{Yes}} {\Return{No}}
+\ClistIfInTF { a , {b} , {b} , c } {d} {\Return{Yes}} {\Return{No}}
\end{demohigh}
%\begin{texnote}
%The function may fail if the \meta{item} contains \verb|{|, \verb|}|, or \verb|#|
@@ -4959,9 +5150,11 @@ of space trimming and brace stripping apply. For example
%\end{texnote}
\end{function}
-\begin{function}{\ClistVarIfIn,\ClistVarIfInTF}
+\begin{function}{\ClistVarIfIn,\ClistVarIfInT,\ClistVarIfInF,\ClistVarIfInTF}
\begin{syntax}
\cs{ClistVarIfIn} \meta{comma list} \Arg{item}
+\cs{ClistVarIfInT} \meta{comma list} \Arg{item} \Arg{true code}
+\cs{ClistVarIfInF} \meta{comma list} \Arg{item} \Arg{false code}
\cs{ClistVarIfInTF} \meta{comma list} \Arg{item} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{item} is present in the \meta{comma list}.
@@ -4969,8 +5162,8 @@ In the case of an \texttt{n}-type \meta{comma list}, the usual rules
of space trimming and brace stripping apply.
\begin{demohigh}
\ClistSet \lTmpaClist {one,two}
-\ClistVarIfInTF \lTmpaClist {one} {\Result{Yes}} {\Result{No}}
-\ClistVarIfInTF \lTmpaClist {three} {\Result{Yes}} {\Result{No}}
+\ClistVarIfInTF \lTmpaClist {one} {\Return{Yes}} {\Return{No}}
+\ClistVarIfInTF \lTmpaClist {three} {\Return{Yes}} {\Return{No}}
\end{demohigh}
%\begin{texnote}
%The function may fail if the \meta{item} contains \verb|{|, \verb|}|, or \verb|#|
@@ -5407,7 +5600,7 @@ not defined in this case and should not be relied upon. If the
the \meta{sequence}. The \meta{token list variable} is assigned locally.
\begin{demohigh}
\SeqSetFromClist \lTmpaSeq {two,three,four}
-\SeqGetTF \lTmpaSeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqGetTF \lTmpaSeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5439,7 +5632,7 @@ not defined in this case and should not be relied upon. If the
in the \meta{token list variable}, \emph{i.e.} removes the item from the
\meta{sequence}. The \meta{token list variable} is assigned locally.
\begin{demohigh}
-\SeqPopTF \cEmptySeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqPopTF \cEmptySeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5496,7 +5689,7 @@ in the \meta{token list variable} without removing it from the
The \meta{token list variable} is assigned locally.
\begin{demohigh}
\SeqSetFromClist \lTmpaSeq {two,three,four}
-\SeqGetLeftTF \lTmpaSeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqGetLeftTF \lTmpaSeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5532,7 +5725,7 @@ in the \meta{token list variable} without removing it from the
The \meta{token list variable} is assigned locally.
\begin{demohigh}
\SeqSetFromClist \lTmpaSeq {two,three,four}
-\SeqGetRightTF \lTmpaSeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqGetRightTF \lTmpaSeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5567,7 +5760,7 @@ in the \meta{token list variable}, \emph{i.e.} removes the item from the
\meta{sequence}, then leaves the \meta{true code} in the input stream.
The \meta{token list variable} is assigned locally.
\begin{demohigh}
-\SeqPopLeftTF \cEmptySeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqPopLeftTF \cEmptySeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5602,7 +5795,7 @@ in the \meta{token list variable}, \emph{i.e.} removes the item from the
\meta{sequence}, then leaves the \meta{true code} in the input stream.
The \meta{token list variable} is assigned locally.
\begin{demohigh}
-\SeqPopRightTF \cEmptySeq \lTmpaTl {\Result{Yes}} {\Result{No}}
+\SeqPopRightTF \cEmptySeq \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -5639,7 +5832,7 @@ The \meta{items} are returned from left to right. For example,
\SeqVarMapInline \lTmpkSeq {
\TlPutRight \lTmpaTl {(#1)}
}
-\Result {\TlUse\lTmpaTl}
+\Return {\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces (one)(two)(three).
@@ -5679,7 +5872,7 @@ or its original value if the \meta{sequence} is empty. The
\SeqVarMapVariable \lTmpaSeq \lTmpiTl {
\IntAdd \lTmpaInt {\lTmpiTl*\lTmpiTl}
}
-\Result {\IntUse\lTmpaInt}
+\Return {\IntUse\lTmpaInt}
\IgnoreSpacesOff
\end{demohigh}
\end{function}
@@ -5795,43 +5988,49 @@ or its original value if the \meta{sequence} is empty. The
\section{Sequence Conditionals}
-\begin{function}{\SeqIfExist,\SeqIfExistTF}
+\begin{function}{\SeqIfExist,\SeqIfExistT,\SeqIfExistF,\SeqIfExistTF}
\begin{syntax}
\cs{SeqIfExist} \meta{sequence}
+\cs{SeqIfExistT} \meta{sequence} \Arg{true code}
+\cs{SeqIfExistF} \meta{sequence} \Arg{false code}
\cs{SeqIfExistTF} \meta{sequence} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{sequence} is currently defined. This does not
check that the \meta{sequence} really is a sequence variable.
\begin{demohigh}
-\SeqIfExistTF \lTmpaSeq {\Result{Yes}} {\Result{No}}
-\SeqIfExistTF \lFooUndefinedSeq {\Result{Yes}} {\Result{No}}
+\SeqIfExistTF \lTmpaSeq {\Return{Yes}} {\Return{No}}
+\SeqIfExistTF \lFooUndefinedSeq {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\SeqVarIfEmpty,\SeqVarIfEmptyTF}
+\begin{function}{\SeqVarIfEmpty,\SeqVarIfEmptyT,\SeqVarIfEmptyF,\SeqVarIfEmptyTF}
\begin{syntax}
\cs{SeqVarIfEmpty} \meta{sequence}
+\cs{SeqVarIfEmptyT} \meta{sequence} \Arg{true code}
+\cs{SeqVarIfEmptyF} \meta{sequence} \Arg{false code}
\cs{SeqVarIfEmptyTF} \meta{sequence} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{sequence} is empty (containing no items).
\begin{demohigh}
\SeqSetFromClist \lTmpaSeq {one,two}
-\SeqVarIfEmptyTF \lTmpaSeq {\Result{Empty}} {\Result{NonEmpty}}
+\SeqVarIfEmptyTF \lTmpaSeq {\Return{Empty}} {\Return{NonEmpty}}
\SeqClear \lTmpaSeq
-\SeqVarIfEmptyTF \lTmpaSeq {\Result{Empty}} {\Result{NonEmpty}}
+\SeqVarIfEmptyTF \lTmpaSeq {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\SeqVarIfIn,\SeqVarIfInTF}
+\begin{function}{\SeqVarIfIn,\SeqVarIfInT,\SeqVarIfInF,\SeqVarIfInTF}
\begin{syntax}
\cs{SeqVarIfIn} \meta{sequence} \Arg{item}
+\cs{SeqVarIfInT} \meta{sequence} \Arg{item} \Arg{true code}
+\cs{SeqVarIfInF} \meta{sequence} \Arg{item} \Arg{false code}
\cs{SeqVarIfInTF} \meta{sequence} \Arg{item} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{item} is present in the \meta{sequence}.
\begin{demohigh}
\SeqSetFromClist \lTmpaSeq {one,two}
-\SeqVarIfInTF \lTmpaSeq {one} {\Result{Yes}} {\Result{Not}}
-\SeqVarIfInTF \lTmpaSeq {three} {\Result{Yes}} {\Result{Not}}
+\SeqVarIfInTF \lTmpaSeq {one} {\Return{Yes}} {\Return{Not}}
+\SeqVarIfInTF \lTmpaSeq {three} {\Return{Yes}} {\Return{Not}}
\end{demohigh}
\end{function}
@@ -6173,7 +6372,7 @@ not be relied upon. If the \meta{key} is present in the
stream. The \meta{token list variable} is assigned locally.
\begin{demohigh}
\PropSetFromKeyval \lTmpaProp {key1=one,key2=two,key3=three}
-\PropGetTF \lTmpaProp {key2} \lTmpaTl {\Result{Yes}} {\Result{No}}
+\PropGetTF \lTmpaProp {key2} \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -6211,7 +6410,7 @@ in the \meta{token list variable}, \emph{i.e.} removes the item from
The \meta{token list variable} is assigned locally.
\begin{demohigh}
\PropSetFromKeyval \lTmpaProp {key1=one,key2=two,key3=three}
-\PropPopTF \lTmpaProp {key2} \lTmpaTl {\Result{Yes}} {\Result{No}}
+\PropPopTF \lTmpaProp {key2} \lTmpaTl {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
@@ -6252,7 +6451,7 @@ For example,
\PropVarMapInline \lTmpkProp {
\TlPutRight \lTmpaTl {(#1=#2)}
}
-\Result {\TlUse\lTmpaTl}
+\Return {\TlUse\lTmpaTl}
\IgnoreSpacesOff
\end{codehigh}
produces (key1=one)(key2=two)(key3=three).
@@ -6332,43 +6531,50 @@ produces (key1=one)(key2=two)(key3=three).
\section{Property List Conditionals}
-\begin{function}{\PropIfExist}
+\begin{function}{\PropIfExist,\PropIfExistT,\PropIfExistF,\PropIfExistTF}
\begin{syntax}
\cs{PropIfExist} \meta{property list}
+\cs{PropIfExistT} \meta{property list} \Arg{true code}
+\cs{PropIfExistF} \meta{property list} \Arg{false code}
\cs{PropIfExistTF} \meta{property list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests whether the \meta{property list} is currently defined. This does not
check that the \meta{property list} really is a property list variable.
\begin{demohigh}
-\PropIfExistTF \lTmpaProp {\Result{Yes}} {\Result{No}}
-\PropIfExistTF \lFooUndefinedProp {\Result{Yes}} {\Result{No}}
+\PropIfExistTF \lTmpaProp {\Return{Yes}} {\Return{No}}
+\PropIfExistTF \lFooUndefinedProp {\Return{Yes}} {\Return{No}}
\end{demohigh}
\end{function}
-\begin{function}{\PropVarIfEmpty}
+\begin{function}{\PropVarIfEmpty,\PropVarIfEmptyT,\PropVarIfEmptyF,\PropVarIfEmptyTF}
\begin{syntax}
\cs{PropVarIfEmpty} \meta{property list}
+\cs{PropVarIfEmptyT} \meta{property list} \Arg{true code}
+\cs{PropVarIfEmptyF} \meta{property list} \Arg{false code}
\cs{PropVarIfEmptyTF} \meta{property list} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{property list} is empty (containing no entries).
\begin{demohigh}
\PropSetFromKeyval \lTmpaProp {key1=one,key2=two}
-\PropVarIfEmptyTF \lTmpaProp {\Result{Empty}} {\Result{NonEmpty}}
+\PropVarIfEmptyTF \lTmpaProp {\Return{Empty}} {\Return{NonEmpty}}
\PropClear \lTmpaProp
-\PropVarIfEmptyTF \lTmpaProp {\Result{Empty}} {\Result{NonEmpty}}
+\PropVarIfEmptyTF \lTmpaProp {\Return{Empty}} {\Return{NonEmpty}}
\end{demohigh}
\end{function}
-\begin{function}{\PropVarIfIn}
+\begin{function}{\PropVarIfIn,\PropVarIfInT,\PropVarIfInF,\PropVarIfInTF}
\begin{syntax}
-\cs{PropVarIfIn} \meta{property list} \Arg{key} \Arg{true code} \Arg{false code}
+\cs{PropVarIfIn} \meta{property list} \Arg{key}
+\cs{PropVarIfInT} \meta{property list} \Arg{key} \Arg{true code}
+\cs{PropVarIfInF} \meta{property list} \Arg{key} \Arg{false code}
+\cs{PropVarIfInTF} \meta{property list} \Arg{key} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{key} is present in the \meta{property list},
making the comparison using the method described by \cs{StrIfEqTF}.
\begin{demohigh}
\PropSetFromKeyval \lTmpaProp {key1=one,key2=two}
-\PropVarIfInTF \lTmpaProp {key1} {\Result{Yes}} {\Result{Not}}
-\PropVarIfInTF \lTmpaProp {key3} {\Result{Yes}} {\Result{Not}}
+\PropVarIfInTF \lTmpaProp {key1} {\Return{Yes}} {\Return{Not}}
+\PropVarIfInTF \lTmpaProp {key3} {\Return{Yes}} {\Return{Not}}
\end{demohigh}
%\begin{texnote}
%This function iterates through every key--value pair in the
@@ -6404,24 +6610,26 @@ by functions such as \cs{PropGet} if there is no data to return.
\section{Quark Conditionals}
-\begin{function}{\QuarkVarIfNoValue,\QuarkVarIfNoValueTF}
+\begin{function}{\QuarkVarIfNoValue,\QuarkVarIfNoValueT,\QuarkVarIfNoValueF,\QuarkVarIfNoValueTF}
\begin{syntax}
\cs{QuarkVarIfNoValue} \meta{token}
+\cs{QuarkVarIfNoValueT} \meta{token} \Arg{true code}
+\cs{QuarkVarIfNoValueF} \meta{token} \Arg{false code}
\cs{QuarkVarIfNoValueTF} \meta{token} \Arg{true code} \Arg{false code}
\end{syntax}
Tests if the \meta{token} is equal to \cs{qNoValue}.
\begin{demohigh}
\ClistGet \cEmptyClist \lTmpaTl
-\QuarkVarIfNoValueTF \lTmpaTl {\Result{NoValue}} {\Result{SomeValue}}
+\QuarkVarIfNoValueTF \lTmpaTl {\Return{NoValue}} {\Return{SomeValue}}
\end{demohigh}
\begin{demohigh}
\SeqPop \cEmptySeq \lTmpaTl
-\QuarkVarIfNoValueTF \lTmpaTl {\Result{NoValue}} {\Result{SomeValue}}
+\QuarkVarIfNoValueTF \lTmpaTl {\Return{NoValue}} {\Return{SomeValue}}
\end{demohigh}
\begin{demohigh}
\PropSetFromKeyval \lTmpaProp {key1=one,key2=two}
\PropGet \lTmpaProp {key3} \lTmpaTl
-\QuarkVarIfNoValueTF \lTmpaTl {\Result{NoValue}} {\Result{SomeValue}}
+\QuarkVarIfNoValueTF \lTmpaTl {\Return{NoValue}} {\Return{SomeValue}}
\end{demohigh}
\end{function}
@@ -6435,6 +6643,57 @@ Tests if the \meta{token} is equal to \cs{qNoValue}.
%\cs{qNoValue} plus one or more other tokens).
%\end{function}
+\chapter{Legacy Concepts (\texttt{Legacy})}
+
+There are a small number of \TeX{} or \LaTeXe{} concepts which are not used
+in \pkg{functional} code but which need to be manipulated when working as a \LaTeXe{}
+package. To allow these to be integrated cleanly into \pkg{functional} code, a set
+of legacy interfaces are provided here.
+
+\begin{function}{\LegacyIf,\LegacyIfT,\LegacyIfF,\LegacyIfTF}
+\begin{syntax}
+\cs{LegacyIf} \Arg{name}
+\cs{LegacyIfT} \Arg{name} \Arg{true code}
+\cs{LegacyIfF} \Arg{name} \Arg{false code}
+\cs{LegacyIfTF} \Arg{name} \Arg{true code} \Arg{false code}
+\end{syntax}
+Tests if the \LaTeXe{}/plain \TeX{} conditional (generated by \tn{newif})
+if \texttt{true} or \texttt{false} and branches \hbox{accordingly}. The
+\meta{name} of the conditional should \emph{omit} the leading \texttt{if}.
+\begin{demohigh}
+\newif \ifFooBar
+\LegacyIfTF {FooBar} {\Return{True!}} {\Return{False!}}
+\end{demohigh}
+\end{function}
+
+\begin{function}{\LegacyIfSetTrue,\LegacyIfSetFalse}
+\begin{syntax}
+\cs{LegacyIfSetTrue} \Arg{name}
+\cs{LegacyIfSetFalse} \Arg{name}
+\end{syntax}
+Sets the \LaTeXe{}/plain \TeX{} conditional \verb|\if|\meta{name}
+(generated by \tn{newif}) to be \texttt{true} or \texttt{false}.
+\begin{demohigh}
+\newif \ifFooBar
+\LegacyIfSetTrue {FooBar}
+\LegacyIfTF {FooBar} {\Return{True!}} {\Return{False!}}
+\end{demohigh}
+\end{function}
+
+\begin{function}{\LegacyIfSet}
+\begin{syntax}
+\cs{LegacyIfSet} \Arg{name} \Arg{boolexpr}
+\end{syntax}
+Sets the \LaTeXe{}/plain \TeX{} conditional \verb|\if|\meta{name}
+(generated by \tn{newif}) to the result of evaluating the
+\meta{boolean expression}.
+\begin{demohigh}
+\newif \ifFooBar
+\LegacyIfSet {FooBar} {\cFalseBool}
+\LegacyIfTF {FooBar} {\Return{True!}} {\Return{False!}}
+\end{demohigh}
+\end{function}
+
\chapter{The Source Code}
%\CodeHigh{lite}