diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3int.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3int.dtx | 167 |
1 files changed, 44 insertions, 123 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx index f1f034553aa..de6e4d72b6a 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3int.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3int.dtx @@ -35,7 +35,7 @@ % %<*driver|package> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3int.dtx 4482 2013-04-24 21:05:12Z joseph $ +\GetIdInfo$Id: l3int.dtx 4581 2013-07-28 08:38:50Z joseph $ {L3 Integers} %</driver|package> %<*driver> @@ -342,25 +342,29 @@ % \end{center} % \end{function} % -% \begin{function}[added = 2012-06-03, EXP]{\int_case:nnn} +% \begin{function}[added = 2013-07-24, EXP, TF]{\int_case:nn} % \begin{syntax} -% \cs{int_case:nnn} \Arg{test integer expression} \\ +% \cs{int_case:nnTF} \Arg{test integer expression} \\ % ~~|{| \\ % ~~~~\Arg{intexpr case_1} \Arg{code case_1} \\ % ~~~~\Arg{intexpr case_2} \Arg{code case_2} \\ % ~~~~\ldots \\ % ~~~~\Arg{intexpr case_n} \Arg{code case_n} \\ % ~~|}| \\ -% ~~\Arg{else code} +% ~~\Arg{true code} +% ~~\Arg{false code} % \end{syntax} % This function evaluates the \meta{test integer expression} and % compares this in turn to each of the % \meta{integer expression cases}. If the two are equal then the -% associated \meta{code} is left in the input stream. If none of -% the tests are \texttt{true} then the \texttt{else code} will be -% left in the input stream. For example +% associated \meta{code} is left in the input stream. If any of the +% cases are matched, the \meta{true code} is also inserted into the +% input stream (after the code for the appropriate case), while if none +% match then the \meta{false code} is inserted. The function +% \cs{int_case:nn}, which does nothing if there is no match, is also +% available. For example % \begin{verbatim} -% \int_case:nnn +% \int_case:nnF % { 2 * 5 } % { % { 5 } { Small } @@ -1464,23 +1468,36 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\int_case:nnn} -% \begin{macro}[aux]{\@@_case:nnn} +% \begin{macro}[EXP]{\int_case:nn} +% \begin{macro}[EXP, TF]{\int_case:nn} +% \begin{macro}[aux]{\@@_case:nnTF} % \begin{macro}[aux]{\@@_case:nw, \@@_case_end:nw} % For integer cases, the first task to fully expand the check -% condition. After that, a loop is started to compare each possible -% value and stop if the test is true. The tested value is put at the -% end to ensure that there is necessarily a match, which will fire the -% \enquote{else} pathway. The leading \tn{romannumeral} triggers an -% expansion which is then stopped in \cs{@@_case_end:nw}. +% condition. The over all idea is then much the same as for +% \cs{str_case:nn(TF)} as described in \pkg{l3basics}. % \begin{macrocode} -\cs_new:Npn \int_case:nnn #1 +\cs_new:Npn \int_case:nnTF #1 + { + \tex_romannumeral:D + \exp_args:Nf \@@_case:nnTF { \int_eval:n {#1} } + } +\cs_new:Npn \int_case:nnT #1#2#3 + { + \tex_romannumeral:D + \exp_args:Nf \@@_case:nnTF { \int_eval:n {#1} } {#2} {#3} { } + } +\cs_new:Npn \int_case:nnF #1#2 + { + \tex_romannumeral:D + \exp_args:Nf \@@_case:nnTF { \int_eval:n {#1} } {#2} { } + } +\cs_new:Npn \int_case:nn #1#2 { \tex_romannumeral:D - \exp_args:Nf \@@_case:nnn { \int_eval:n {#1} } + \exp_args:Nf \@@_case:nnTF { \int_eval:n {#1} } {#2} { } { } } -\cs_new:Npn \@@_case:nnn #1#2#3 - { \@@_case:nw {#1} #2 {#1} {#3} \q_recursion_stop } +\cs_new:Npn \@@_case:nnTF #1#2#3#4 + { \@@_case:nw {#1} #2 {#1} { } \q_mark {#3} \q_mark {#4} \q_stop } \cs_new:Npn \@@_case:nw #1#2#3 { \int_compare:nNnTF {#1} = {#2} @@ -1492,6 +1509,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \begin{macro}[pTF]{\int_if_odd:n} % \UnitTested @@ -1720,13 +1738,13 @@ { \exp_args:NNo \exp_args:No \@@_to_symbols:nnnn { - \int_case:nnn + \int_case:nn { 1 + \int_mod:nn { #1 - 1 } {#2} } - {#3} { } + {#3} } {#1} {#2} {#3} } - { \int_case:nnn {#1} {#3} { } } + { \int_case:nn {#1} {#3} } } \cs_new:Npn \@@_to_symbols:nnnn #1#2#3#4 { @@ -1863,7 +1881,7 @@ } % \end{macrocode} % Convert to a letter only if necessary, otherwise simply return the -% value unchanged. It would be cleaner to use \cs{int_case:nnn}, +% value unchanged. It would be cleaner to use \cs{int_case:nn}, % but in our case, the cases are contiguous, so it is forty times faster % to use the \cs{if_case:w} primitive. The first \cs{exp_after:wN} % expands the conditional, jumping to the correct case, the second one @@ -2338,107 +2356,10 @@ % % \subsection{Deprecated functions} % -% Deprecated on 2011-05-27, for removal by 2011-08-31. -% -% \begin{macro}{\int_convert_from_base_ten:nn} -% \begin{macro}{\int_convert_to_symbols:nnn} -% \begin{macro}{\int_convert_to_base_ten:nn} -% Some simple renames. -% \begin{macrocode} -%<*deprecated> -\cs_new_eq:NN \int_convert_from_base_ten:nn \int_to_base:nn -\cs_new_eq:NN \int_convert_to_symbols:nnn \int_to_symbols:nnn -\cs_new_eq:NN \int_convert_to_base_ten:nn \int_from_base:nn -%</deprecated> -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\int_to_symbol:n} -% \begin{macro}[aux]{\int_to_symbol_math:n} -% \begin{macro}[aux]{\int_to_symbol_text:n} -% \UnitTested -% This is rather too tied to \LaTeXe{}. -% \begin{macrocode} -%<*deprecated> -\cs_new_nopar:Npn \int_to_symbol:n - { - \scan_align_safe_stop: - \mode_if_math:TF - { \int_to_symbol_math:n } - { \int_to_symbol_text:n } - } -\cs_new:Npn \int_to_symbol_math:n #1 - { - \int_to_symbols:nnn {#1} { 9 } - { - { 1 } { * } - { 2 } { \dagger } - { 3 } { \ddagger } - { 4 } { \mathsection } - { 5 } { \mathparagraph } - { 6 } { \| } - { 7 } { ** } - { 8 } { \dagger \dagger } - { 9 } { \ddagger \ddagger } - } - } -\cs_new:Npn \int_to_symbol_text:n #1 - { - \int_to_symbols:nnn {#1} { 9 } - { - { 1 } { \textasteriskcentered } - { 2 } { \textdagger } - { 3 } { \textdaggerdbl } - { 4 } { \textsection } - { 5 } { \textparagraph } - { 6 } { \textbardbl } - { 7 } { \textasteriskcentered \textasteriskcentered } - { 8 } { \textdagger \textdagger } - { 9 } { \textdaggerdbl \textdaggerdbl } - } - } -%</deprecated> -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\if_num:w} -% Deprecated 2012-05-30 for removal after 2012-11-30. -% \begin{macrocode} -%<*deprecated> -\cs_new_eq:NN \if_num:w \if_int_compare:w -%</deprecated> -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\l_tmpc_int} -% Deprecated 2012-07-04 for removal after 2012-12-31. -% \begin{macrocode} -%<*deprecated> -\int_new:N \l_tmpc_int -%</deprecated> -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\int_eval:w, \int_eval_end:} -% Deprecated 2012-07-13 for removal after 2012-12-31. -% \begin{macrocode} -%<*deprecated> -\cs_new_eq:NN \int_eval:w \@@_eval:w -\cs_new_eq:NN \int_eval_end: \@@_eval_end: -%</deprecated> -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\int_value:w} -% Deprecated 2012-07-14 for removal after 2012-12-31. +% \begin{macro}{\int_case:nnn} +% Deprecated 2013-07-15. % \begin{macrocode} -%<*deprecated> -\cs_new_eq:NN \int_value:w \@@_value:w -%</deprecated> +\cs_new_eq:NN \int_case:nnn \int_case:nnF % \end{macrocode} % \end{macro} % |