summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3prg.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3prg.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3prg.dtx110
1 files changed, 107 insertions, 3 deletions
diff --git a/macros/latex/contrib/l3kernel/l3prg.dtx b/macros/latex/contrib/l3kernel/l3prg.dtx
index e8e4bbf4f1..1324b1eb42 100644
--- a/macros/latex/contrib/l3kernel/l3prg.dtx
+++ b/macros/latex/contrib/l3kernel/l3prg.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2023-04-20}
+% \date{Released 2023-05-05}
%
% \maketitle
%
@@ -304,6 +304,18 @@
% the logical truth of this evaluation.
% \end{function}
%
+% \begin{function}[added = 2018-05-10]
+% {
+% \bool_set_inverse:N , \bool_set_inverse:c ,
+% \bool_gset_inverse:N, \bool_gset_inverse:c
+% }
+% \begin{syntax}
+% \cs{bool_set_inverse:N} \meta{boolean}
+% \end{syntax}
+% Toggles the \meta{boolean} from \texttt{true} to \texttt{false} and
+% conversely: sets it to the inverse of its current value.
+% \end{function}
+%
% \begin{function}[EXP,pTF, updated = 2017-07-15]{\bool_if:N, \bool_if:c}
% \begin{syntax}
% \cs{bool_if_p:N} \meta{boolean}
@@ -625,6 +637,45 @@
% then loops until the \meta{boolean expression} is \texttt{false}.
% \end{function}
%
+% \begin{function}[added = 2023-05-03, EXP, noTF]{\bool_case:n}
+% \begin{syntax}
+% \cs{bool_case:nTF} \\
+% ~~|{| \\
+% ~~~~\Arg{boolexpr case_1} \Arg{code case_1} \\
+% ~~~~\Arg{boolexpr case_2} \Arg{code case_2} \\
+% ~~~~\ldots \\
+% ~~~~\Arg{boolexpr case_n} \Arg{code case_n} \\
+% ~~|}| \\
+% ~~\Arg{true code}
+% ~~\Arg{false code}
+% \end{syntax}
+% Evaluates in turn each of the \meta{boolean expression cases} until
+% the first one that evaluates to \texttt{true}.
+% The \meta{code} associated to this first case is left in the input
+% stream, followed by the \meta{true code}, and other cases are
+% discarded. If none of the cases match then only the \meta{false
+% code} is inserted. The function \cs{bool_case_true:n},
+% which does nothing if there is no match, is
+% also available. For example
+% \begin{verbatim}
+% \bool_case:nF
+% {
+% { \dim_compare_p:n { \l__mypkg_wd_dim <= 10pt } }
+% { Fits }
+% { \int_compare_p:n { \l__mypkg_total_int >= 10 } }
+% { Many }
+% { \l__mypkg_special_bool }
+% { Special }
+% }
+% { No idea! }
+% \end{verbatim}
+% leaves \enquote{\texttt{Fits}} or \enquote{\texttt{Many}} or
+% \enquote{\texttt{Special}} or \enquote{\texttt{No idea!}} in the
+% input stream, in a way similar to some other language's
+% \enquote{\texttt{if} \ldots\ \texttt{elseif} \ldots\ \texttt{elseif} \ldots\
+% \texttt{else} \ldots}.
+% \end{function}
+%
% \section{Producing multiple copies}
%
% \begin{function}[updated = 2011-07-04, EXP]{\prg_replicate:nn}
@@ -929,6 +980,19 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[added = 2018-05-10]
+% {\bool_set_inverse:N, \bool_set_inverse:c, \bool_gset_inverse:N, \bool_gset_inverse:c}
+% Set to \texttt{false} or \texttt{true} locally or globally.
+% \begin{macrocode}
+\cs_new_protected:Npn \bool_set_inverse:N #1
+ { \bool_if:NTF #1 { \bool_set_false:N } { \bool_set_true:N } #1 }
+\cs_generate_variant:Nn \bool_set_inverse:N { c }
+\cs_new_protected:Npn \bool_gset_inverse:N #1
+ { \bool_if:NTF #1 { \bool_gset_false:N } { \bool_gset_true:N } #1 }
+\cs_generate_variant:Nn \bool_gset_inverse:N { c }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Internal auxiliaries}
%
% \begin{variable}{\q_@@_recursion_tail,\q_@@_recursion_stop}
@@ -984,9 +1048,9 @@
% Show the truth value of the boolean.
% \begin{macrocode}
\cs_new_protected:Npn \bool_show:n
- { \msg_show_eval:Nn \bool_to_str:n }
+ { \__kernel_msg_show_eval:Nn \bool_to_str:n }
\cs_new_protected:Npn \bool_log:n
- { \msg_log_eval:Nn \bool_to_str:n }
+ { \__kernel_msg_log_eval:Nn \bool_to_str:n }
% \end{macrocode}
% \end{macro}
%
@@ -1458,6 +1522,46 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{variable}{\s_@@_mark,\s_@@_stop}
+% Internal scan marks.
+% \begin{macrocode}
+\scan_new:N \s_@@_mark
+\scan_new:N \s_@@_stop
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}[EXP, noTF]{\bool_case:n}
+% \begin{macro}{\@@_case:NnTF}
+% \begin{macro}{\@@_case:w,a\@@_case_end:nw}
+% For boolean cases the overall idea is the same as for
+% \cs{tl_case:nnTF} as described in \pkg{l3tl}.
+% \begin{macrocode}
+\cs_new:Npn \bool_case:nTF
+ { \exp:w \@@_case:nTF }
+\cs_new:Npn \bool_case:nT #1#2
+ { \exp:w \@@_case:nTF {#1} {#2} { } }
+\cs_new:Npn \bool_case:nF #1
+ { \exp:w \@@_case:nTF {#1} { } }
+\cs_new:Npn \bool_case:n #1
+ { \exp:w \@@_case:nTF {#1} { } { } }
+\cs_new:Npn \@@_case:nTF #1#2#3
+ {
+ \@@_case:w
+ #1 \c_true_bool { } \s_@@_mark {#2} \s_@@_mark {#3} \s_@@_stop
+ }
+\cs_new:Npn \@@_case:w #1#2
+ {
+ \bool_if:nTF {#1}
+ { \@@_case_end:nw {#2} }
+ { \@@_case:w }
+ }
+\cs_new:Npn \@@_case_end:nw #1#2#3 \s_@@_mark #4#5 \s_@@_stop
+ { \exp_end: #1 #4 }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Producing multiple copies}
%
% \begin{macrocode}