summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3int.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3int.dtx382
1 files changed, 205 insertions, 177 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
index 2d9deaf1210..58c13e5ec41 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx
@@ -41,7 +41,7 @@
% }^^A
% }
%
-% \date{Released 2018/03/05}
+% \date{Released 2018-04-30}
%
% \maketitle
%
@@ -92,6 +92,17 @@
% \end{texnote}
% \end{function}
%
+% \begin{function}[EXP, added = 2018-03-30]{\int_eval:w}
+% \begin{syntax}
+% \cs{int_eval:w} \Arg{integer expression}
+% \end{syntax}
+% Evaluates the \meta{integer expression} as described for
+% \cs{int_eval:n}. The end of the expression is the first token
+% encountered that cannot form part of such an expression.
+% If that token is \cs{scan_stop:} it is removed, otherwise not.
+% Spaces do \emph{not} terminate the expression.
+% \end{function}
+%
% \begin{function}[EXP, updated = 2012-09-26]{\int_abs:n}
% \begin{syntax}
% \cs{int_abs:n} \Arg{integer expression}
@@ -481,9 +492,11 @@
%
% \section{Integer step functions}
%
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30, rEXP]
-% {\int_step_function:nnnN}
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22, rEXP]
+% {\int_step_function:nN, \int_step_function:nnN, \int_step_function:nnnN}
% \begin{syntax}
+% \cs{int_step_function:nN} \Arg{final value} \meta{function}
+% \cs{int_step_function:nnN} \Arg{initial value} \Arg{final value} \meta{function}
% \cs{int_step_function:nnnN} \Arg{initial value} \Arg{step} \Arg{final value} \meta{function}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
@@ -508,11 +521,18 @@
% [I saw 4] \quad
% [I saw 5] \quad
% \end{quote}
+%
+% The functions \cs{int_step_function:nN} and \cs{int_step_function:nnN}
+% both use a fixed \meta{step} of $1$, and in the case of
+% \cs{int_step_function:nN} the \meta{initial value} is also fixed as
+% $1$. These functions are provided as simple short-cuts for code clarity.
% \end{function}
%
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30]
-% {\int_step_inline:nnnn}
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22]
+% {\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn}
% \begin{syntax}
+% \cs{int_step_inline:nn} \Arg{final value} \Arg{code}
+% \cs{int_step_inline:nnn} \Arg{initial value} \Arg{final value} \Arg{code}
% \cs{int_step_inline:nnnn} \Arg{initial value} \Arg{step} \Arg{final value} \Arg{code}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
@@ -522,13 +542,19 @@
% \meta{value}), the \meta{code} is inserted into the input stream
% with |#1| replaced by the current \meta{value}. Thus the
% \meta{code} should define a function of one argument~(|#1|).
+%
+% The functions \cs{int_step_inline:nn} and \cs{int_step_inline:nnn}
+% both use a fixed \meta{step} of $1$, and in the case of
+% \cs{int_step_inline:nn} the \meta{initial value} is also fixed as
+% $1$. These functions are provided as simple short-cuts for code clarity.
% \end{function}
%
-% \begin{function}[added = 2012-06-04, updated = 2014-05-30]
-% {\int_step_variable:nnnNn}
+% \begin{function}[added = 2012-06-04, updated = 2018-04-22]
+% {\int_step_variable:nnn, \int_step_variable:nnnn, \int_step_variable:nnnnn}
% \begin{syntax}
-% \cs{int_step_variable:nnnNn} \\
-% ~~\Arg{initial value} \Arg{step} \Arg{final value} \meta{tl~var} \Arg{code}
+% \cs{int_step_variable:nNn} \Arg{final value} \meta{tl~var} \Arg{code}
+% \cs{int_step_variable:nnNn} \Arg{initial value} \Arg{final value} \meta{tl~var} \Arg{code}
+% \cs{int_step_variable:nnnNn} \Arg{initial value} \Arg{step} \Arg{final value} \meta{tl~var} \Arg{code}
% \end{syntax}
% This function first evaluates the \meta{initial value}, \meta{step}
% and \meta{final value}, all of which should be integer expressions.
@@ -537,6 +563,11 @@
% \meta{value}), the \meta{code} is inserted into the input stream,
% with the \meta{tl~var} defined as the current \meta{value}. Thus
% the \meta{code} should make use of the \meta{tl~var}.
+%
+% The functions \cs{int_step_variable:nNn} and \cs{int_step_variable:nnNn}
+% both use a fixed \meta{step} of $1$, and in the case of
+% \cs{int_step_variable:nNn} the \meta{initial value} is also fixed as
+% $1$. These functions are provided as simple short-cuts for code clarity.
% \end{function}
%
% \section{Formatting integers}
@@ -753,6 +784,17 @@
% \cs{int_to_Base:nn}.
% \end{function}
%
+% \section{Random integers}
+%
+% \begin{function}[EXP, added = 2016-12-06, updated = 2018-04-27]{\int_rand:nn}
+% \begin{syntax}
+% \cs{int_rand:nn} \Arg{intexpr_1} \Arg{intexpr_2}
+% \end{syntax}
+% Evaluates the two \meta{integer expressions} and produces a
+% pseudo-random number between the two (with bounds included). This
+% is not yet available in \XeTeX{}.
+% \end{function}
+%
% \section{Viewing integers}
%
% \begin{function}{\int_show:N, \int_show:c}
@@ -846,6 +888,38 @@
% code and so should only be used for short-term storage.
% \end{variable}
%
+% \subsection{Direct number expansion}
+%
+% \begin{function}[EXP, added = 2018-03-27]{\int_value:w}
+% \begin{syntax}
+% \cs{int_value:w} \meta{integer}
+% \cs{int_value:w} \meta{integer denotation} \meta{optional space}
+% \end{syntax}
+% Expands the following tokens until an \meta{integer} is formed, and
+% leaves a normalized form (no leading sign except for negative
+% numbers, no leading digit~|0| except for zero) in the input stream
+% as category code $12$ (other) characters. The \meta{integer} can
+% consist of any number of signs (with intervening spaces) followed
+% by
+% \begin{itemize}
+% \item an integer variable (in fact, any \TeX{} register except
+% \tn{toks}) or
+% \item explicit digits (or by |'|\meta{octal digits} or |"|\meta{hexadecimal digits} or |`|\meta{character}).
+% \end{itemize}
+% In this last case expansion stops once a non-digit is found; if that is a
+% space it is removed as in \texttt{f}-expansion, and so \cs{exp_stop_f:}
+% may be employed as an end marker. Note that protected functions
+% \emph{are} expanded by this process.
+%
+% This function requires exactly one expansion to produce a value, and so
+% is suitable for use in cases where a number is required \enquote{directly}.
+% In general, \cs{int_eval:n} is the preferred approach to generating
+% numbers.
+% \begin{texnote}
+% This is the \TeX{} primitive \tn{number}.
+% \end{texnote}
+% \end{function}
+%
% \section{Primitive conditionals}
%
% \begin{function}[EXP]{\if_int_compare:w}
@@ -898,86 +972,6 @@
% \end{texnote}
% \end{function}
%
-% \section{Internal functions}
-%
-% \begin{function}[EXP]{\__int_value:w}
-% \begin{syntax}
-% \cs{__int_value:w} \meta{integer}
-% \cs{__int_value:w} \meta{integer denotation} \meta{optional space}
-% \end{syntax}
-% Expands the following tokens until an \meta{integer} is formed, and
-% leaves a normalized form (no leading sign except for negative
-% numbers, no leading digit~|0| except for zero) in the input stream
-% as category code $12$ (other) characters. The \meta{integer} can
-% consist of any number of signs (with intervening spaces) followed
-% by
-% \begin{itemize}
-% \item an integer variable (in fact, any \TeX{} register except
-% \tn{toks}) or
-% \item \cs{__int_eval:w} \meta{intexpr} \cs{__int_eval_end:} (or
-% another \eTeX{} expression) or
-% \item explicit digits (or by |'|\meta{octal digits} or |"|\meta{hexadecimal digits} or |`|\meta{character}
-% \end{itemize}
-% In this last case expansion stops once a non-digit is found; if that is a space it is removed as in \texttt{f}-expansion.
-% Note that protected functions \emph{are} expanded by this process
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{number}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}[EXP]{\__int_to_roman:w}
-% \begin{syntax}
-% \cs{__int_to_roman:w} \meta{integer}
-% \cs{__int_to_roman:w} \meta{integer denotation} \meta{optional space}
-% \end{syntax}
-% Converts an \meta{integer} to lower case Roman representation. The
-% \meta{integer} is found as in \cs{__int_value:w} by expanding what
-% follows exhaustively. One (optional) space is lost if the
-% \meta{integer} is given by explicit digits. Note that this function
-% produces a string of letters with category code~$12$. Negative
-% \meta{integer} values result in no output, although the function
-% does not terminate expansion until a suitable endpoint is found in
-% the same way as for positive numbers.
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{romannumeral} renamed.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}[EXP]{\__int_eval:w, \__int_eval_end:}
-% \begin{syntax}
-% \cs{__int_eval:w} \meta{intexpr} \cs{__int_eval_end:}
-% \end{syntax}
-% Evaluates \meta{integer expression} as described for \cs{int_eval:n}.
-% The evaluation stops when an unexpandable token which is not a valid
-% part of an integer is read or when \cs{__int_eval_end:} is
-% reached. The latter is gobbled by the scanner mechanism:
-% \cs{__int_eval_end:} itself is unexpandable but used correctly
-% the entire construct is expandable.
-% \begin{texnote}
-% This is the \eTeX{} primitive \tn{numexpr}.
-% \end{texnote}
-% \end{function}
-%
-% \begin{function}[EXP]{\__int_eval:n}
-% \begin{syntax}
-% \cs{__int_eval:n} \Arg{intexpr}
-% \end{syntax}
-% By default this expands to \cs{__int_eval:w} \meta{intexpr}
-% \cs{__int_eval_end:} but when debugging is enabled this expands to a
-% more complicated construction that evaluates \meta{intexpr} with
-% parentheses and within a brace group to detect early termination.
-% \end{function}
-%
-% \begin{function}{\__prg_compare_error:, \__prg_compare_error:Nw}
-% \begin{syntax}
-% \cs{__prg_compare_error:}
-% \cs{__prg_compare_error:Nw} \meta{token}
-% \end{syntax}
-% These are used within \cs{int_compare:nTF}, \cs{dim_compare:nTF}
-% and so on to recover correctly if the \texttt{n}-type argument does not
-% contain a properly-formed relation.
-% \end{function}
-%
% \end{documentation}
%
% \begin{implementation}
@@ -1008,7 +1002,7 @@
% Done in \pkg{l3basics}.
% \end{macro}
%
-% \begin{macro}{\@@_value:w}
+% \begin{macro}{\int_value:w}
% \begin{macro}{\@@_eval:w}
% \begin{macro}{\@@_eval_end:}
% \begin{macro}{\if_int_odd:w}
@@ -1016,7 +1010,7 @@
% Here are the remaining primitives for number comparisons and
% expressions.
% \begin{macrocode}
-\cs_new_eq:NN \@@_value:w \tex_number:D
+\cs_new_eq:NN \int_value:w \tex_number:D
\cs_new_eq:NN \@@_eval:w \etex_numexpr:D
\cs_new_eq:NN \@@_eval_end: \tex_relax:D
\cs_new_eq:NN \if_int_odd:w \tex_ifodd:D
@@ -1031,6 +1025,7 @@
% \subsection{Integer expressions}
%
% \begin{macro}{\int_eval:n}
+% \begin{macro}{\int_eval:w}
% Wrapper for \cs{@@_eval:w}: can be used in an integer expression
% or directly in the input stream.
% When debugging, use parentheses to catch early termination.
@@ -1038,19 +1033,10 @@
\__kernel_patch_args:nNNpn
{ { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \int_eval:n } }
\cs_new:Npn \int_eval:n #1
- { \@@_value:w \@@_eval:w #1 \@@_eval_end: }
+ { \int_value:w \@@_eval:w #1 \@@_eval_end: }
+\cs_new:Npn \int_eval:w { \int_value:w \@@_eval:w }
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\@@_eval:n}
-% Only differ from \cs{int_eval:n} by the absence of \cs{@@_value:w},
-% so as to produce an internal integer rather than expanding into
-% characters. This is for use in other modules.
-% \begin{macrocode}
-\__kernel_patch_args:nNNpn
- { { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \@@_eval:n } }
-\cs_new:Npn \@@_eval:n #1 { \@@_eval:w #1 \@@_eval_end: }
-% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]{\int_abs:n}
@@ -1069,8 +1055,8 @@
{ { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \int_abs:n } }
\cs_new:Npn \int_abs:n #1
{
- \@@_value:w \exp_after:wN \@@_abs:N
- \@@_value:w \@@_eval:w #1 \@@_eval_end:
+ \int_value:w \exp_after:wN \@@_abs:N
+ \int_value:w \@@_eval:w #1 \@@_eval_end:
\exp_stop_f:
}
\cs_new:Npn \@@_abs:N #1
@@ -1082,9 +1068,9 @@
}
\cs_set:Npn \int_max:nn #1#2
{
- \@@_value:w \exp_after:wN \@@_maxmin:wwN
- \@@_value:w \@@_eval:w #1 \exp_after:wN ;
- \@@_value:w \@@_eval:w #2 ;
+ \int_value:w \exp_after:wN \@@_maxmin:wwN
+ \int_value:w \@@_eval:w #1 \exp_after:wN ;
+ \int_value:w \@@_eval:w #2 ;
>
\exp_stop_f:
}
@@ -1095,9 +1081,9 @@
}
\cs_set:Npn \int_min:nn #1#2
{
- \@@_value:w \exp_after:wN \@@_maxmin:wwN
- \@@_value:w \@@_eval:w #1 \exp_after:wN ;
- \@@_value:w \@@_eval:w #2 ;
+ \int_value:w \exp_after:wN \@@_maxmin:wwN
+ \int_value:w \@@_eval:w #1 \exp_after:wN ;
+ \int_value:w \@@_eval:w #2 ;
<
\exp_stop_f:
}
@@ -1144,10 +1130,10 @@
}
\cs_new:Npn \int_div_truncate:nn #1#2
{
- \@@_value:w \@@_eval:w
+ \int_value:w \@@_eval:w
\exp_after:wN \@@_div_truncate:NwNw
- \@@_value:w \@@_eval:w #1 \exp_after:wN ;
- \@@_value:w \@@_eval:w #2 ;
+ \int_value:w \@@_eval:w #1 \exp_after:wN ;
+ \int_value:w \@@_eval:w #2 ;
\@@_eval_end:
}
\cs_new:Npn \@@_div_truncate:NwNw #1#2; #3#4;
@@ -1167,7 +1153,7 @@
% For the sake of completeness:
% \begin{macrocode}
\cs_new:Npn \int_div_round:nn #1#2
- { \@@_value:w \@@_eval:w ( #1 ) / ( #2 ) \@@_eval_end: }
+ { \int_value:w \@@_eval:w ( #1 ) / ( #2 ) \@@_eval_end: }
% \end{macrocode}
% Finally there's the modulus operation.
% \begin{macrocode}
@@ -1178,9 +1164,9 @@
}
\cs_new:Npn \int_mod:nn #1#2
{
- \@@_value:w \@@_eval:w \exp_after:wN \@@_mod:ww
- \@@_value:w \@@_eval:w #1 \exp_after:wN ;
- \@@_value:w \@@_eval:w #2 ;
+ \int_value:w \@@_eval:w \exp_after:wN \@@_mod:ww
+ \int_value:w \@@_eval:w #1 \exp_after:wN ;
+ \int_value:w \@@_eval:w #2 ;
\@@_eval_end:
}
\cs_new:Npn \@@_mod:ww #1; #2;
@@ -1205,7 +1191,7 @@
%<*package>
\cs_new_protected:Npn \int_new:N #1
{
- \__chk_if_free_cs:N #1
+ \__kernel_chk_if_free_cs:N #1
\cs:w newcount \cs_end: #1
}
%</package>
@@ -1215,7 +1201,7 @@
%
% \begin{macro}{\int_const:Nn, \int_const:cn}
% \begin{macro}{\@@_constdef:Nw}
-% \begin{variable}{\c__max_constdef_int}
+% \begin{variable}{\c_@@_max_constdef_int}
% \UnitTested
% As stated, most constants can be defined as \tn{chardef} or
% \tn{mathchardef} but that's engine dependent. As a result, there is some
@@ -1236,13 +1222,13 @@
\tex_global:D
}
{
- \int_compare:nNnTF {#2} > \c__max_constdef_int
+ \int_compare:nNnTF {#2} > \c_@@_max_constdef_int
{
\int_new:N #1
\tex_global:D
}
{
- \__chk_if_free_cs:N #1
+ \__kernel_chk_if_free_cs:N #1
\tex_global:D \@@_constdef:Nw
}
}
@@ -1257,10 +1243,10 @@
\cs_if_exist:NTF \uptex_disablecjktoken:D
{ \cs_new_eq:NN \@@_constdef:Nw \uptex_kchardef:D }
{ \cs_new_eq:NN \@@_constdef:Nw \tex_chardef:D }
- \@@_constdef:Nw \c__max_constdef_int 1114111 ~
+ \@@_constdef:Nw \c_@@_max_constdef_int 1114111 ~
\else:
\cs_new_eq:NN \@@_constdef:Nw \tex_mathchardef:D
- \tex_mathchardef:D \c__max_constdef_int 32767 ~
+ \tex_mathchardef:D \c_@@_max_constdef_int 32767 ~
\fi:
% \end{macrocode}
% \end{variable}
@@ -1449,27 +1435,27 @@
%
% \subsection{Integer expression conditionals}
%
-% \begin{macro}[EXP]{\__prg_compare_error:, \__prg_compare_error:Nw}
+% \begin{macro}[EXP]{\@@_compare_error:, \@@_compare_error:Nw}
% Those functions are used for comparison tests which use a simple
% syntax where only one set of braces is required and additional
% operators such as |!=| and |>=| are supported. The tests first
% evaluate their left-hand side, with a trailing
-% \cs{__prg_compare_error:}. This marker is normally not expanded,
+% \cs{@@_compare_error:}. This marker is normally not expanded,
% but if the relation symbol is missing from the test's argument, then
% the marker inserts |=| (and itself) after triggering the relevant
% \TeX{} error. If the first token which appears after evaluating and
% removing the left-hand side is not a known relation symbol, then a
-% judiciously placed \cs{__prg_compare_error:Nw} gets expanded,
+% judiciously placed \cs{@@_compare_error:Nw} gets expanded,
% cleaning up the end of the test and telling the user what the
% problem was.
% \begin{macrocode}
-\cs_new_protected:Npn \__prg_compare_error:
+\cs_new_protected:Npn \@@_compare_error:
{
\if_int_compare:w \c_zero \c_zero \fi:
=
- \__prg_compare_error:
+ \@@_compare_error:
}
-\cs_new:Npn \__prg_compare_error:Nw
+\cs_new:Npn \@@_compare_error:Nw
#1#2 \q_stop
{
{ }
@@ -1513,7 +1499,7 @@
% of the \TeX{} conditional is taken (because of \cs{reverse_if:N}),
% immediately returning \texttt{false} as the result of the test.
% There is no \TeX{} conditional waiting the first operand, so we add
-% an \cs{if_false:} and expand by hand with \cs{@@_value:w}, thus
+% an \cs{if_false:} and expand by hand with \cs{int_value:w}, thus
% skipping \cs{prg_return_false:} on the first iteration.
%
% Before starting the loop, the first step is to make sure that there
@@ -1521,7 +1507,7 @@
% left hand side of the (in)equality using \cs{@@_eval:w}. Since the
% relation symbols |<|, |>|, |=| and |!| are not allowed in integer
% expressions, they would terminate the expression. If the argument contains no
-% relation symbol, \cs{__prg_compare_error:} is expanded,
+% relation symbol, \cs{@@_compare_error:} is expanded,
% inserting~|=| and itself after an error. In all cases,
% \cs{@@_compare:w} receives as its argument an integer, a relation
% symbol, and some more tokens. We then setup the loop, which is
@@ -1531,11 +1517,11 @@
\prg_new_conditional:Npnn \int_compare:n #1 { p , T , F , TF }
{
\exp_after:wN \@@_compare:w
- \@@_value:w \@@_eval:w #1 \__prg_compare_error:
+ \int_value:w \@@_eval:w #1 \@@_compare_error:
}
-\cs_new:Npn \@@_compare:w #1 \__prg_compare_error:
+\cs_new:Npn \@@_compare:w #1 \@@_compare_error:
{
- \exp_after:wN \if_false: \@@_value:w
+ \exp_after:wN \if_false: \int_value:w
\@@_compare:Nw #1 e { = nd_ } \q_stop
}
% \end{macrocode}
@@ -1551,7 +1537,7 @@
% hence the test for that as a second token. If the relation symbol
% is unknown, then the control sequence is turned by \TeX{} into
% \cs{scan_stop:}, ignored thanks to \tn{unexpanded}, and
-% \cs{__prg_compare_error:Nw} raises an error.
+% \cs{@@_compare_error:Nw} raises an error.
% \begin{macrocode}
\cs_new:Npn \@@_compare:Nw #1#2 \q_stop
{
@@ -1561,14 +1547,14 @@
}
\cs_new:Npn \@@_compare:NNw #1#2#3 \q_mark
{
- \etex_unexpanded:D
+ \__kernel_exp_not:w
\use:c
{
@@_compare_ \token_to_str:N #1
\if_meaning:w = #2 = \fi:
:NNw
}
- \__prg_compare_error:Nw #1
+ \@@_compare_error:Nw #1
}
% \end{macrocode}
% When the last \meta{operand} is seen, \cs{@@_compare:NNw} receives
@@ -1596,12 +1582,12 @@
{#2} \exp_stop_f:
\prg_return_false: \exp_after:wN \use_none_delimit_by_q_stop:w
\fi:
- #1 #2 #3 \exp_after:wN \@@_compare:Nw \@@_value:w \@@_eval:w
+ #1 #2 #3 \exp_after:wN \@@_compare:Nw \int_value:w \@@_eval:w
}
% \end{macrocode}
% The actual comparisons are then simple function calls, using the
% relation as delimiter for a delimited argument and discarding
-% \cs{__prg_compare_error:Nw} \meta{token} responsible for error
+% \cs{@@_compare_error:Nw} \meta{token} responsible for error
% detection.
% \begin{macrocode}
\cs_new:cpn { @@_compare_=:NNw } #1#2#3 =
@@ -1649,7 +1635,7 @@
% \begin{macro}{\@@_case:nw, \@@_case_end:nw}
% For integer cases, the first task to fully expand the check
% condition. The over all idea is then much the same as for
-% \cs{str_case:nn(TF)} as described in \pkg{l3basics}.
+% \cs{tl_case:nn(TF)} as described in \pkg{l3tl}.
% \begin{macrocode}
\cs_new:Npn \int_case:nnTF #1
{
@@ -1679,7 +1665,8 @@
{ \@@_case_end:nw {#3} }
{ \@@_case:nw {#1} }
}
-\cs_new_eq:NN \@@_case_end:nw \__prg_case_end:nw
+\cs_new:Npn \@@_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
+ { \exp_end: #1 #4 }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1810,7 +1797,9 @@
% \subsection{Integer step functions}
%
% \begin{macro}{\int_step_function:nnnN}
-% \begin{macro}{\@@_step:wwwN, \@@_step:NnnnN}
+% \begin{macro}{\@@_step:wwwN, \@@_step:NwnnN}
+% \begin{macro}{\int_step_function:nN}
+% \begin{macro}{\int_step_function:nnN}
% Before all else, evaluate the initial value, step, and final value.
% Repeating a function by steps first needs a check on the direction
% of the steps. After that, do the function for the start value then
@@ -1820,70 +1809,96 @@
% \begin{macrocode}
\__kernel_patch_args:nNNpn
{
- { \__kernel_chk_expr:nNnN {#1} \@@_eval:w { } \int_step_function:nnnN }
- { \__kernel_chk_expr:nNnN {#2} \@@_eval:w { } \int_step_function:nnnN }
- { \__kernel_chk_expr:nNnN {#3} \@@_eval:w { } \int_step_function:nnnN }
+ {
+ \__kernel_chk_expr:nNnN {#1} \@@_eval:w { }
+ \int_step_function:nnnN
+ }
+ {
+ \__kernel_chk_expr:nNnN {#2} \@@_eval:w { }
+ \int_step_function:nnnN
+ }
+ {
+ \__kernel_chk_expr:nNnN {#3} \@@_eval:w { }
+ \int_step_function:nnnN
+ }
}
\cs_new:Npn \int_step_function:nnnN #1#2#3
{
\exp_after:wN \@@_step:wwwN
- \@@_value:w \@@_eval:w #1 \exp_after:wN ;
- \@@_value:w \@@_eval:w #2 \exp_after:wN ;
- \@@_value:w \@@_eval:w #3 ;
+ \int_value:w \@@_eval:w #1 \exp_after:wN ;
+ \int_value:w \@@_eval:w #2 \exp_after:wN ;
+ \int_value:w \@@_eval:w #3 ;
}
\cs_new:Npn \@@_step:wwwN #1; #2; #3; #4
{
\int_compare:nNnTF {#2} > \c_zero
- { \@@_step:NnnnN > }
+ { \@@_step:NwnnN > }
{
\int_compare:nNnTF {#2} = \c_zero
{
- \__kernel_msg_expandable_error:nnn { kernel } { zero-step } {#4}
- \use_none:nnnn
+ \__kernel_msg_expandable_error:nnn
+ { kernel } { zero-step } {#4}
+ \prg_break:
}
- { \@@_step:NnnnN < }
+ { \@@_step:NwnnN < }
}
- {#1} {#2} {#3} #4
+ #1 ; {#2} {#3} #4
+ \prg_break_point:
}
-\cs_new:Npn \@@_step:NnnnN #1#2#3#4#5
+\cs_new:Npn \@@_step:NwnnN #1#2 ; #3#4#5
{
- \int_compare:nNnF {#2} #1 {#4}
- {
- #5 {#2}
- \exp_args:NNf \@@_step:NnnnN
- #1 { \int_eval:n { #2 + #3 } } {#3} {#4} #5
- }
- }
+ \if_int_compare:w #2 #1 #4 \exp_stop_f:
+ \prg_break:n
+ \fi:
+ #5 {#2}
+ \exp_after:wN \@@_step:NwnnN
+ \exp_after:wN #1
+ \int_value:w \@@_eval:w #2 + #3 ; {#3} {#4} #5
+ }
+\cs_new:Npn \int_step_function:nN
+ { \int_step_function:nnnN { 1 } { 1 } }
+\cs_new:Npn \int_step_function:nnN #1
+ { \int_step_function:nnnN {#1} { 1 } }
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
-% \begin{macro}{\int_step_inline:nnnn}
-% \begin{macro}{\int_step_variable:nnnNn}
+% \begin{macro}{\int_step_inline:nn, \int_step_inline:nnn, \int_step_inline:nnnn}
+% \begin{macro}{\int_step_variable:nNn, \int_step_variable:nnNn, \int_step_variable:nnnNn}
% \UnitTested
% \begin{macro}{\@@_step:NNnnnn}
% The approach here is to build a function, with a global integer
% required to make the nesting safe (as seen in other in line
% functions), and map that function using \cs{int_step_function:nnnN}.
-% We put a \cs{__prg_break_point:Nn} so that \texttt{map_break}
-% functions from other modules correctly decrement \cs{g__prg_map_int}
+% We put a \cs{prg_break_point:Nn} so that \texttt{map_break}
+% functions from other modules correctly decrement \cs{g__kernel_prg_map_int}
% before looking for their own break point. The first argument is
% \cs{scan_stop:}, so that no breaking function recognizes this break
% point as its own.
% \begin{macrocode}
+\cs_new_protected:Npn \int_step_inline:nn
+ { \int_step_inline:nnnn { 1 } { 1 } }
+\cs_new_protected:Npn \int_step_inline:nnn #1
+ { \int_step_inline:nnnn {#1} { 1 } }
\cs_new_protected:Npn \int_step_inline:nnnn
{
- \int_gincr:N \g__prg_map_int
+ \int_gincr:N \g__kernel_prg_map_int
\exp_args:NNc \@@_step:NNnnnn
\cs_gset_protected:Npn
- { __prg_map_ \int_use:N \g__prg_map_int :w }
+ { @@_map_ \int_use:N \g__kernel_prg_map_int :w }
}
+\cs_new_protected:Npn \int_step_variable:nNn
+ { \int_step_variable:nnnNn { 1 } { 1 } }
+\cs_new_protected:Npn \int_step_variable:nnNn #1
+ { \int_step_variable:nnnNn {#1} { 1 } }
\cs_new_protected:Npn \int_step_variable:nnnNn #1#2#3#4#5
{
- \int_gincr:N \g__prg_map_int
+ \int_gincr:N \g__kernel_prg_map_int
\exp_args:NNc \@@_step:NNnnnn
\cs_gset_protected:Npx
- { __prg_map_ \int_use:N \g__prg_map_int :w }
+ { @@_map_ \int_use:N \g__kernel_prg_map_int :w }
{#1}{#2}{#3}
{
\tl_set:Nn \exp_not:N #4 {##1}
@@ -1894,7 +1909,7 @@
{
#1 #2 ##1 {#6}
\int_step_function:nnnN {#3} {#4} {#5} #2
- \__prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__prg_map_int }
+ \prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__kernel_prg_map_int }
}
% \end{macrocode}
% \end{macro}
@@ -2139,7 +2154,7 @@
\or: x
\or: y
\or: z
- \else: \@@_value:w \@@_eval:w #1 \exp_after:wN \@@_eval_end:
+ \else: \int_value:w \@@_eval:w #1 \exp_after:wN \@@_eval_end:
\fi:
}
\cs_new:Npn \@@_to_Letter:n #1
@@ -2172,7 +2187,7 @@
\or: X
\or: Y
\or: Z
- \else: \@@_value:w \@@_eval:w #1 \exp_after:wN \@@_eval_end:
+ \else: \int_value:w \@@_eval:w #1 \exp_after:wN \@@_eval_end:
\fi:
}
% \end{macrocode}
@@ -2479,6 +2494,12 @@
% \end{macrocode}
% \end{macro}
%
+%\subsection{Random integers}
+%
+% \begin{macro}{\int_rand:nn}
+% Defined in \pkg{l3fp-random}.
+% \end{macro}
+%
% \subsection{Constant integers}
%
% \begin{variable}{\c_zero}
@@ -2590,15 +2611,22 @@
% \cs{c_minus_one} (as all deprecated commands) is made outer by
% \cs{debug_deprecation_on:}.
% \begin{macrocode}
-%<package>\cs_gset_eq:NN \c__deprecation_minus_one \m@ne
-%<initex>\int_const:Nn \c__deprecation_minus_one { -1 }
-\cs_new_eq:NN \c_minus_one \c__deprecation_minus_one
+%<package>\cs_gset_eq:NN \c_@@_minus_one \m@ne
+%<initex>\int_const:Nn \c_@@_minus_one { -1 }
+\cs_new_eq:NN \c_minus_one \c_@@_minus_one
\__kernel_deprecation_code:nn
- { \__deprecation_error:Nnn \c_minus_one { -1 } { 2018-12-31 } }
- { \tex_let:D \c_minus_one \c__deprecation_minus_one }
+ { \__kernel_deprecation_error:Nnn \c_minus_one { -1 } { 2018-12-31 } }
+ { \tex_let:D \c_minus_one \c_@@_minus_one }
% \end{macrocode}
% \end{variable}
%
+% \begin{macro}[deprecated = 2019-12-31]{\@@_value:w}
+% Made public.
+% \begin{macrocode}
+\cs_new_eq:NN \@@_value:w \int_value:w
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}