diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3int.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expl3/l3int.dtx | 265 |
1 files changed, 137 insertions, 128 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3int.dtx b/Master/texmf-dist/source/latex/expl3/l3int.dtx index 93fa6d7e6d1..fac6c0245f3 100644 --- a/Master/texmf-dist/source/latex/expl3/l3int.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3int.dtx @@ -36,7 +36,7 @@ \RequirePackage{l3names} %</driver|package> %\fi -\GetIdInfo$Id: l3int.dtx 2121 2011-01-07 08:46:09Z joseph $ +\GetIdInfo$Id: l3int.dtx 2178 2011-03-06 09:03:44Z mittelba $ {L3 Experimental Integer module} %\iffalse %<*driver> @@ -372,8 +372,7 @@ %\subsection{Comparing integer expressions} % %\begin{function}{ -% \int_compare_p:nNn / (EXP) | -% \int_compare:nNn / (EXP) (TF) | +% \int_compare:nNn / (EXP) (pTF) | %} % \begin{syntax} % \cs{int_compare_p:nNn} @@ -400,8 +399,7 @@ %\end{function} % %\begin{function}{ -% \int_compare_p:n / (EXP) | -% \int_compare:n / (EXP) (TF) | +% \int_compare:n / (EXP) (pTF) | %} % \begin{syntax} % \cs{int_compare_p:n} @@ -431,10 +429,8 @@ %\end{function} % %\begin{function}{ -% \int_if_even_p:n / (EXP) | -% \int_if_even:n / (EXP) (TF) | -% \int_if_odd_p:n / (EXP) | -% \int_if_odd:n / (EXP) (TF) | +% \int_if_even:n / (EXP) (pTF) | +% \int_if_odd:n / (EXP) (pTF) | %} % \begin{syntax} % \cs{int_if_odd_p:n} \Arg{integer expression} @@ -967,6 +963,8 @@ % % \section{\pkg{l3int} implementation} % +% \TestFiles{m3int001.lvt,m3int002.lvt,m3int03.lvt} +% % \subsection{Internal functions and variables} % % \begin{function}{\int_advance:w} @@ -1064,6 +1062,7 @@ % \subsection{Allocation and setting} % % \begin{macro}{\int_new:N,\int_new:c} +% \UnitTested % For the \LaTeX3 format: % \begin{macrocode} %<*initex> @@ -1085,10 +1084,10 @@ % \end{macro} % % -% \begin{macro}{\int_set:Nn} -% \begin{macro}{\int_set:cn} -% \begin{macro}{\int_gset:Nn} -% \begin{macro}{\int_gset:cn} +% \begin{macro}{\int_set:Nn, \int_set:cn} +% \UnitTested +% \begin{macro}{\int_gset:Nn,\int_gset:cn} +% \UnitTested % Setting counters is again something that I would like to make % uniform at the moment to get a better overview. % \begin{macrocode} @@ -1108,17 +1107,16 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} % -%\begin{macro}{\int_set_eq:NN} -%\begin{macro}{\int_set_eq:cN} -%\begin{macro}{\int_set_eq:Nc} -%\begin{macro}{\int_set_eq:cc} -%\begin{macro}{\int_gset_eq:NN} -%\begin{macro}{\int_gset_eq:cN} -%\begin{macro}{\int_gset_eq:Nc} -%\begin{macro}{\int_gset_eq:cc} +% +% +% +%\begin{macro}{\int_set_eq:NN,\int_set_eq:cN, +% \int_set_eq:Nc,\int_set_eq:cc} +% \UnitTested +%\begin{macro}{\int_gset_eq:NN,\int_gset_eq:cN, +% \int_gset_eq:Nc,\int_gset_eq:cc} +% \UnitTested % Setting equal means using one integer inside the set function of % another. % \begin{macrocode} @@ -1137,21 +1135,18 @@ % \end{macrocode} %\end{macro} %\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} % -% \begin{macro}{\int_incr:N} -% \begin{macro}{\int_decr:N} -% \begin{macro}{\int_gincr:N} -% \begin{macro}{\int_gdecr:N} -% \begin{macro}{\int_incr:c} -% \begin{macro}{\int_decr:c} -% \begin{macro}{\int_gincr:c} -% \begin{macro}{\int_gdecr:c} +% +% +% +% \begin{macro}{\int_incr:N,\int_incr:c} +% \UnitTested +% \begin{macro}{\int_decr:N,\int_decr:c} +% \UnitTested +% \begin{macro}{\int_gincr:N,\int_gincr:c} +% \UnitTested +% \begin{macro}{\int_gdecr:N,\int_gdecr:c} +% \UnitTested % Incrementing and decrementing of integer registers is done with % the following functions. % \begin{macrocode} @@ -1206,16 +1201,12 @@ % \end{macro} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} % % -% \begin{macro}{\int_zero:N} -% \begin{macro}{\int_zero:c} -% \begin{macro}{\int_gzero:N} -% \begin{macro}{\int_gzero:c} +% \begin{macro}{\int_zero:N,\int_zero:c} +% \UnitTested +% \begin{macro}{\int_gzero:N,\int_gzero:c} +% \UnitTested % Functions that reset an \m{int} register to zero. % \begin{macrocode} \cs_new_protected_nopar:Npn \int_zero:N #1 {#1=\c_zero} @@ -1228,17 +1219,15 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} % -% \begin{macro}{\int_add:Nn} -% \begin{macro}{\int_add:cn} -% \begin{macro}{\int_gadd:Nn} -% \begin{macro}{\int_gadd:cn} -% \begin{macro}{\int_sub:Nn} -% \begin{macro}{\int_sub:cn} -% \begin{macro}{\int_gsub:Nn} -% \begin{macro}{\int_gsub:cn} +% \begin{macro}{\int_add:Nn,\int_add:cn} +% \UnitTested +% \begin{macro}{\int_gadd:Nn,\int_gadd:cn} +% \UnitTested +% \begin{macro}{\int_sub:Nn,\int_sub:cn} +% \UnitTested +% \begin{macro}{\int_gsub:Nn,\int_gsub:cn} +% \UnitTested % Adding and substracting to and from a counter \ldots % We should think of using these functions % \begin{macrocode} @@ -1280,35 +1269,31 @@ % \end{macro} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} % % -% \begin{macro}{\int_use:N} -% \begin{macro}{\int_use:c} +% \begin{macro}{\int_use:N,\int_use:c} +% \UnitTested % Here is how counters are accessed: % \begin{macrocode} \cs_new_eq:NN \int_use:N \tex_the:D \cs_new_nopar:Npn \int_use:c #1{\int_use:N \cs:w#1\cs_end:} % \end{macrocode} % \end{macro} -% \end{macro} % -% \begin{macro}{\int_show:N} -% \begin{macro}{\int_show:c} +% +% \begin{macro}{\int_show:N,\int_show:c} +% \UnitTested % \begin{macrocode} \cs_new_eq:NN \int_show:N \kernel_register_show:N \cs_new_eq:NN \int_show:c \kernel_register_show:c % \end{macrocode} % \end{macro} -% \end{macro} % % % % % \begin{macro}{\int_to_arabic:n} +% \UnitTested % Nothing exciting here. % \begin{macrocode} \cs_new_nopar:Npn \int_to_arabic:n #1{ \int_eval:n{#1}} @@ -1317,7 +1302,7 @@ % % % -% \begin{macro}{\int_roman_lcuc_mapping:Nnn} +% \begin{macro}[aux]{\int_roman_lcuc_mapping:Nnn} % Using \TeX's built-in feature for producing roman numerals has some % surprising features. One is the the characters resulting from % |\int_to_roman:w| have category code~12 so they may fail in @@ -1331,6 +1316,8 @@ } % \end{macrocode} % \end{macro} +% +% % Here are the default mappings. I haven't found any examples of say % Turkish doing the mapping |i \i I| but at least there is a % possibility for it if needed. Note: I have now asked a Turkish @@ -1349,9 +1336,10 @@ \int_roman_lcuc_mapping:Nnn Q \use_none:nn \use_none:nn % \end{macrocode} % -% \begin{macro}{\int_to_roman:n} -% \begin{macro}{\int_to_Roman:n} -% \begin{macro}{\int_to_roman_lcuc:NN} +% \begin{macro}{\int_to_roman:n, \int_to_Roman:n} +% \UnitTested +% \TestMissing{output is catcode 11} +% \begin{macro}[aux]{\int_to_roman_lcuc:NN} % The commands for producing the lower and upper case roman numerals % run a loop on one character at a time and also carries some % information for upper or lower case with it. We put it through @@ -1372,20 +1360,20 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} +% % %\begin{macro}{\int_convert_to_symbols:nnn} -% For conversion of integers to arbitrary symbols the method is in -% general as follows. The input number ("#1") is compared to the total -% number of symbols available at each place ("#2"). If the input is -% larger than the total number of symbols available then the modulus -% is needed, with one added so that the positions don't have to number -% from zero. Using an \texttt{f}-type expansion, this is done so that -% the system is recursive. The actual conversion function therefore -% gets a `nice' number at each stage. Of course, if the initial input -% was small enough then there is no problem and everything is easy. This -% is more or less the same as \cs{int_convert_number_with_rule:nnN} but -% `pre-packaged'. +%\UnitTested +% For conversion of integers to arbitrary symbols the method is in +% general as follows. The input number ("#1") is compared to the total +% number of symbols available at each place ("#2"). If the input is larger +% than the total number of symbols available then the modulus is needed, +% with one added so that the positions don't have to number from +% zero. Using an \texttt{f}-type expansion, this is done so that the system +% is recursive. The actual conversion function therefore gets a `nice' +% number at each stage. Of course, if the initial input was small enough +% then there is no problem and everything is easy. This is more or less the +% same as \cs{int_convert_number_with_rule:nnN} but `pre-packaged'. % \begin{macrocode} \cs_new_nopar:Npn \int_convert_to_symbols:nnn #1#2#3 { \int_compare:nNnTF {#1} > {#2} @@ -1446,8 +1434,8 @@ % \end{macro} % % -%\begin{macro}{\int_to_alph:n} -%\begin{macro}{\int_to_Alph:n} +%\begin{macro}{\int_to_alph:n,\int_to_Alph:n} +%\UnitTested % These both use the above function with input functions that make sense % for the alphabet in English. % \begin{macrocode} @@ -1515,9 +1503,10 @@ } % \end{macrocode} %\end{macro} -%\end{macro} +% % % \begin{macro}{\int_to_symbol:n} +% \UnitTested % Turning a number into a symbol is also easy enough. % \begin{macrocode} \cs_new_nopar:Npn \int_to_symbol:n #1{ @@ -1533,6 +1522,9 @@ } % \end{macrocode} % \end{macro} +% +% +% % \begin{macro}{\int_symbol_math_conversion_rule:n} % \begin{macro}{\int_symbol_text_conversion_rule:n} % Nothing spectacular here. @@ -1567,11 +1559,11 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\l_tmpa_int} -% \begin{macro}{\l_tmpb_int} -% \begin{macro}{\l_tmpc_int} -% \begin{macro}{\g_tmpa_int} -% \begin{macro}{\g_tmpb_int} +% \begin{macro}[aux]{\l_tmpa_int} +% \begin{macro}[aux]{\l_tmpb_int} +% \begin{macro}[aux]{\l_tmpc_int} +% \begin{macro}[aux]{\g_tmpa_int} +% \begin{macro}[aux]{\g_tmpb_int} % We provide four local and two global scratch counters, maybe we % need more or less. % \begin{macrocode} @@ -1612,7 +1604,9 @@ % \subsection{Scanning and conversion} % % -%\begin{macro}{\int_from_roman:n} +% \begin{macro}{\int_from_roman:n} +% \UnitTested +% \TestMissing{boundary cases / wrong input?} %\begin{macro}[aux]{\int_from_roman_aux:NN} %\begin{macro}[aux]{\int_from_roman_end:w} %\begin{macro}[aux]{\int_from_roman_clean_up:w} @@ -1671,9 +1665,14 @@ %\end{macro} %\end{macro} % +% +% +% %\begin{macro}{\int_convert_from_base_ten:nn} +% \UnitTested %\begin{macro}[aux]{\int_convert_from_base_ten_aux:nnn} %\begin{macro}{\int_convert_number_to_letter:n} +% \UnitTested % Converting from base ten ("#1") to a second base ("#2") starts with % a simple sign check. As the input is base \( 10 \) \TeX\ can then % do the actual work with the sign itself. @@ -1760,6 +1759,7 @@ %\end{macro} % %\begin{macro}{\int_convert_to_base_ten:nn} +% \UnitTested %\begin{macro}[aux]{\int_convert_to_base_ten_aux:nn} %\begin{macro}[aux]{\int_convert_to_base_ten_aux:nnN} %\begin{macro}[aux]{\int_convert_to_base_ten_aux:N} @@ -1862,12 +1862,10 @@ %\end{macro} %\end{macro} % -%\begin{macro}{\int_from_binary:n} -%\begin{macro}{\int_from_hexadecimal:n} -%\begin{macro}{\int_from_octal:n} -%\begin{macro}{\int_to_binary:n} -%\begin{macro}{\int_to_hexadecimal:n} -%\begin{macro}{\int_to_octal:n} +%\begin{macro}{\int_from_binary:n,\int_from_hexadecimal:n,\int_from_octal:n} +% \UnitTested +%\begin{macro}{\int_to_binary:n,\int_to_hexadecimal:n,\int_to_octal:n} +% \UnitTested % Wrappers around the generic function. % \begin{macrocode} \cs_new:Npn \int_from_binary:n #1 { @@ -1891,12 +1889,11 @@ % \end{macrocode} %\end{macro} %\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} -%\end{macro} +% +% % %\begin{macro}{\int_from_alph:n} +% \UnitTested %\begin{macro}[aux]{\int_from_alph_aux:n} %\begin{macro}[aux]{\int_from_alph_aux:nN} %\begin{macro}[aux]{\int_from_alph_aux:N} @@ -1934,8 +1931,7 @@ %\end{macro} % % -% \begin{macro}{\int_compare_p:n} -% \begin{macro}[TF]{\int_compare:n} +% \begin{macro}[pTF]{\int_compare:n} % Comparison tests using a simple syntax where only one set of braces % is required and additional operators such as "!=" and ">=" are % supported. First some notes on the idea behind this. We wish to @@ -2031,10 +2027,10 @@ } % \end{macrocode} % \end{macro} -% \end{macro} % -% \begin{macro}{\int_compare_p:nNn} -% \begin{macro}[TF]{\int_compare:nNn} +% +% \begin{macro}[pTF]{\int_compare:nNn} +% \UnitTested % More efficient but less natural in typing. % \begin{macrocode} \prg_set_conditional:Npnn \int_compare:nNn #1#2#3{p}{ @@ -2065,11 +2061,14 @@ } % \end{macrocode} % \end{macro} -% \end{macro} +% % % \begin{macro}{\int_max:nn} +% \UnitTested % \begin{macro}{\int_min:nn} +% \UnitTested % \begin{macro}{\int_abs:n} +% \UnitTested % Functions for $\min$, $\max$, and absolute value. % \begin{macrocode} \cs_set:Npn \int_abs:n #1{ @@ -2106,8 +2105,11 @@ % % % \begin{macro}{\int_div_truncate:nn} +% \UnitTested % \begin{macro}{\int_div_round:nn} +% \UnitTested % \begin{macro}{\int_mod:nn} +% \UnitTested % As "\int_eval:w" rounds the result of a division we also % provide a version that truncates the result. % \begin{macrocode} @@ -2162,10 +2164,11 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\int_if_odd_p:n} -% \begin{macro}[TF]{\int_if_odd:n} -% \begin{macro}{\int_if_even_p:n} -% \begin{macro}[TF]{\int_if_even:n} +% +% \begin{macro}[pTF]{\int_if_odd:n} +% \UnitTested +% \begin{macro}[pTF]{\int_if_even:n} +% \UnitTested % A predicate function. % \begin{macrocode} \prg_set_conditional:Npnn \int_if_odd:n #1 {p,TF,T,F} { @@ -2179,13 +2182,20 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} +% % % \begin{macro}{\int_while_do:nn} +% \UnitTested +% \TestMissing{Boundary cases} % \begin{macro}{\int_until_do:nn} +% \UnitTested +% \TestMissing{Boundary cases} % \begin{macro}{\int_do_while:nn} +% \UnitTested +% \TestMissing{Boundary cases} % \begin{macro}{\int_do_until:nn} +% \UnitTested +% \TestMissing{Boundary cases} % These are quite easy given the above functions. The "while" versions % test first and then execute the body. The "do_while" does it the % other way round. @@ -2208,6 +2218,7 @@ % \end{macro} % \end{macro} % +% % \begin{macro}{\int_while_do:nNnn} % \begin{macro}{\int_until_do:nNnn} % \begin{macro}{\int_do_while:nNnn} @@ -2232,10 +2243,11 @@ % \end{macro} % \end{macro} % - +% % \subsection{Defining constants} -% \begin{macro}{\int_const:Nn} -% \begin{macro}{\int_const:cn} +% +% \begin{macro}{\int_const:Nn, \int_const:cn} +% \UnitTested % As stated, most constants can be defined as |\tex_chardef:D| or % |\tex_mathchardef:D| but that's engine dependent. % \begin{macrocode} @@ -2260,15 +2272,7 @@ \cs_generate_variant:Nn \int_const:Nn { c } % \end{macrocode} % \end{macro} -% \end{macro} % -%\begin{macro}{\c_max_register_int} -% This is here as this particular integer is needed both in package -% mode and to bootstrap \pkg{l3alloc} -% \begin{macrocode} -\tex_mathchardef:D \c_max_register_int = 32767 \scan_stop: -% \end{macrocode} -% \end{macro} % % \begin{macro}{\c_minus_one, % \c_zero, \c_one, \c_two, \c_three, \c_four, \c_five, \c_six, @@ -2282,6 +2286,10 @@ % \c_ten_thousand_one, \c_ten_thousand_two, % \c_ten_thousand_three, \c_ten_thousand_four, % \c_twenty_thousand} +% \TestMissing{Too simple for tests, but they aren't aux, so perhaps we should +% add a test that they actually represent their numbers after +% all} +% \UnitTested % And the usual constants, others are still missing. Please, make % every constant a real constant at least for the moment. We can % easily convert things in the end when we have found what @@ -2289,19 +2297,19 @@ % \begin{macrocode} %% \tex_countdef:D \c_minus_one = 10 \scan_stop: %% \c_minus_one = -1 \scan_stop: %% in l3basics -%\int_const:Nn \c_zero {0} +%\int_const:Nn \c_zero {0} %% in l3basics \int_const:Nn \c_one {1} \int_const:Nn \c_two {2} \int_const:Nn \c_three {3} \int_const:Nn \c_four {4} \int_const:Nn \c_five {5} -\int_const:Nn \c_six {6} -\int_const:Nn \c_seven {7} +%\int_const:Nn \c_six {6} %% in l3basics +%\int_const:Nn \c_seven {7} %% in l3basics \int_const:Nn \c_eight {8} \int_const:Nn \c_nine {9} \int_const:Nn \c_ten {10} \int_const:Nn \c_eleven {11} -\int_const:Nn \c_twelve {12} +%\int_const:Nn \c_twelve {12} %% in l3basics \int_const:Nn \c_thirteen {13} \int_const:Nn \c_fourteen {14} \int_const:Nn \c_fifteen {15} @@ -2377,9 +2385,10 @@ %\end{macro} %\end{macro} % -% Needed from the tl module: +% Needed from other modules: % \begin{macrocode} \int_new:N \g_tl_inline_level_int +\int_new:N\g_prg_inline_level_int % \end{macrocode} % % \subsection{Backwards compatibility} |