diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/expl3/l3int.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/expl3/l3int.sty | 378 |
1 files changed, 173 insertions, 205 deletions
diff --git a/Master/texmf-dist/tex/latex/expl3/l3int.sty b/Master/texmf-dist/tex/latex/expl3/l3int.sty index 7c9ea287861..3ab5772e28a 100644 --- a/Master/texmf-dist/tex/latex/expl3/l3int.sty +++ b/Master/texmf-dist/tex/latex/expl3/l3int.sty @@ -15,7 +15,7 @@ %% Do not distribute a modified version of this file. %% %% -%% File: l3int.dtx Copyright (C) 1990-2008 LaTeX3 project +%% File: l3int.dtx Copyright (C) 1990-2009 LaTeX3 project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -33,7 +33,7 @@ %% %% The development version of the bundle can be found at %% -%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% @@ -48,68 +48,72 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3int.dtx 738 2008-08-01 13:21:42Z morten $ +\GetIdInfo$Id: l3int.dtx 1362 2009-05-28 20:19:21Z joseph $ {L3 Experimental Integer module} - \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} -\RequirePackage{l3num} -\let_new:NN \int_to_roman:w \tex_romannumeral:D -\let_new:NN \int_to_number:w \tex_number:D -\let_new:NN \int_advance:w \tex_advance:D -\def_new:Npn \int_incr:N #1{\int_advance:w#1\c_one +\package_check_loaded_expl: +\cs_new_eq:NN \int_to_roman:w \tex_romannumeral:D +\cs_new_eq:NN \int_to_number:w \tex_number:D +\cs_new_eq:NN \int_advance:w \tex_advance:D +\cs_new_nopar:Npn \int_new:N #1 { + \chk_if_free_cs:N #1 + \newcount #1 +} +\cs_generate_variant:Nn \int_new:N {c} +\cs_new_nopar:Npn \int_set:Nn #1#2{#1 \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \int_gset:Nn { + \pref_global:D + \int_set:Nn } +\cs_generate_variant:Nn\int_set:Nn {cn} +\cs_generate_variant:Nn\int_gset:Nn {cn} +\cs_new_nopar:Npn \int_incr:N #1{\int_advance:w#1\c_one } -\def_new:Npn \int_decr:N #1{\int_advance:w#1\c_minus_one +\cs_new_nopar:Npn \int_decr:N #1{\int_advance:w#1\c_minus_one } -\def_new:Npn \int_gincr:N { +\cs_new_nopar:Npn \int_gincr:N { \pref_global:D \int_incr:N} -\def_new:Npn \int_gdecr:N { +\cs_new_nopar:Npn \int_gdecr:N { \pref_global:D \int_decr:N} -\def:Npn \int_incr:N #1{\int_add:Nn#1\c_one} -\def:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one} -\def:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one} -\def:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one} -\def:Npn \int_incr:c {\exp_args:Nc\int_incr:N} -\def:Npn \int_decr:c {\exp_args:Nc\int_decr:N} -\def:Npn \int_gincr:c {\exp_args:Nc\int_gincr:N} -\def:Npn \int_gdecr:c {\exp_args:Nc\int_gdecr:N} -\let:NN \int_new:N \newcount% allocation better nick the LaTeX one... -\def_new:Npn \int_new:c {\exp_args:Nc \int_new:N} -\def_new:Npn \int_set:Nn #1#2{#1 \int_eval:w #2\int_eval_end: -} -\def_new:Npn \int_gset:Nn { - \pref_global:D - \int_set:Nn } -\def_new:Npn \int_set:cn {\exp_args:Nc \int_set:Nn } -\def_new:Npn \int_gset:cn {\exp_args:Nc \int_gset:Nn } -\def_new:Npn \int_zero:N #1 {#1=\c_zero} -\def_new:Npn \int_zero:c #1 {\exp_args:Nc \int_zero:N} -\def_new:Npn \int_gzero:N #1 {\pref_global:D #1=\c_zero} -\def_new:Npn \int_gzero:c {\exp_args:Nc \int_gzero:N} -\def_new:Npn \int_add:Nn #1#2{ - \int_advance:w #1 by \int_eval:w #2\int_eval_end: -} -\def_new:Npn\int_add:cn{\exp_args:Nc\int_add:Nn} -\def_new:Npn \int_sub:Nn #1#2{ - \int_advance:w #1-\int_eval:w #2\int_eval_end: -} -\def_new:Npn \int_gadd:Nn { +\cs_set_nopar:Npn \int_incr:N #1{\int_add:Nn#1\c_one} +\cs_set_nopar:Npn \int_decr:N #1{\int_add:Nn#1\c_minus_one} +\cs_set_nopar:Npn \int_gincr:N #1{\int_gadd:Nn#1\c_one} +\cs_set_nopar:Npn \int_gdecr:N #1{\int_gadd:Nn#1\c_minus_one} +\cs_generate_variant:Nn \int_incr:N {c} +\cs_generate_variant:Nn \int_decr:N {c} +\cs_generate_variant:Nn \int_gincr:N {c} +\cs_generate_variant:Nn \int_gdecr:N {c} +\cs_new_nopar:Npn \int_zero:N #1 {#1=\c_zero} +\cs_generate_variant:Nn \int_zero:N {c} +\cs_new_nopar:Npn \int_gzero:N #1 {\pref_global:D #1=\c_zero} +\cs_generate_variant:Nn \int_gzero:N {c} +\cs_new_nopar:Npn \int_add:Nn #1#2{ + \int_advance:w #1 by \intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \int_sub:Nn #1#2{ + \int_advance:w #1-\intexpr_eval:w #2\intexpr_eval_end: +} +\cs_new_nopar:Npn \int_gadd:Nn { \pref_global:D \int_add:Nn } -\def_new:Npn \int_gsub:Nn { +\cs_new_nopar:Npn \int_gsub:Nn { \pref_global:D \int_sub:Nn } -\def_new:Npn \int_gadd:cn{\exp_args:Nc\int_gadd:Nn} -\def_new:Npn \int_sub:cn{\exp_args:Nc\int_sub:Nn} -\def_new:Npn \int_gsub:cn{\exp_args:Nc\int_gsub:Nn} -\let_new:NN \int_use:N \tex_the:D -\def_new:Npn \int_use:c #1{\int_use:N \cs:w#1\cs_end:} -\def_new:Npn \int_to_arabic:n #1{\int_to_number:w \int_eval:n{#1}} -\def_new:Npn \int_roman_lcuc_mapping:Nnn #1#2#3{ - \def:cpn {int_to_lc_roman_#1:}{#2} - \def:cpn {int_to_uc_roman_#1:}{#3} +\cs_generate_variant:Nn \int_add:Nn {cn} +\cs_generate_variant:Nn \int_gadd:Nn {cn} +\cs_generate_variant:Nn \int_sub:Nn {cn} +\cs_generate_variant:Nn \int_gsub:Nn {cn} +\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:} +\cs_new_eq:NN \int_show:N \tex_showthe:D +\cs_new_nopar:Npn \int_show:c {\exp_args:Nc \int_show:N } +\cs_new_nopar:Npn \int_to_arabic:n #1{ \intexpr_eval:n{#1}} +\cs_new_nopar:Npn \int_roman_lcuc_mapping:Nnn #1#2#3{ + \cs_set_nopar:cpn {int_to_lc_roman_#1:}{#2} + \cs_set_nopar:cpn {int_to_uc_roman_#1:}{#3} } \int_roman_lcuc_mapping:Nnn i i I \int_roman_lcuc_mapping:Nnn v v V @@ -119,29 +123,29 @@ \int_roman_lcuc_mapping:Nnn d d D \int_roman_lcuc_mapping:Nnn m m M \int_roman_lcuc_mapping:Nnn Q \use_none:nn \use_none:nn -\def_new:Npn \int_to_roman:n #1 { - \exp_after:NN \int_to_roman_lcuc:NN \exp_after:NN l - \int_to_roman:w \int_eval:n {#1} Q +\cs_new_nopar:Npn \int_to_roman:n #1 { + \exp_after:wN \int_to_roman_lcuc:NN \exp_after:wN l + \int_to_roman:w \intexpr_eval:n {#1} Q } -\def_new:Npn \int_to_Roman:n #1 { - \exp_after:NN \int_to_roman_lcuc:NN \exp_after:NN u - \int_to_roman:w \int_eval:n {#1} Q +\cs_new_nopar:Npn \int_to_Roman:n #1 { + \exp_after:wN \int_to_roman_lcuc:NN \exp_after:wN u + \int_to_roman:w \intexpr_eval:n {#1} Q } -\def_new:Npn \int_to_roman_lcuc:NN #1#2{ - \cs_use:c {int_to_#1c_roman_#2:} +\cs_new_nopar:Npn \int_to_roman_lcuc:NN #1#2{ + \use:c {int_to_#1c_roman_#2:} \int_to_roman_lcuc:NN #1 } -\def:Npn \int_convert_number_with_rule:nnN #1#2#3{ - \int_compare:nNnTF {#1}>{#2} +\cs_set_nopar:Npn \int_convert_number_with_rule:nnN #1#2#3{ + \intexpr_compare:nNnTF {#1}>{#2} { - \exp_args:No \int_convert_number_with_rule:nnN - { \int_use:N\int_div_truncate:nn {#1-1}{#2} }{#2} + \exp_args:Nf \int_convert_number_with_rule:nnN + { \intexpr_div_truncate:nn {#1-1}{#2} }{#2} #3 - \exp_args:No #3 { \int_use:N\int_eval:n{1+\int_mod:nn {#1-1}{#2}} } + \exp_args:Nf #3 { \intexpr_eval:n{1+\intexpr_mod:nn {#1-1}{#2}} } } - { \exp_args:No #3{ \int_use:N\int_eval:n{#1} } } + { \exp_args:Nf #3{ \intexpr_eval:n{#1} } } } -\def_new:Npn \int_alph_default_conversion_rule:n #1{ +\cs_new_nopar:Npn \int_alph_default_conversion_rule:n #1{ \if_case:w #1 \or: a\or: b\or: c\or: d\or: e\or: f \or: g\or: h\or: i\or: j\or: k\or: l @@ -150,7 +154,7 @@ \or: y\or: z \fi: } -\def_new:Npn \int_Alph_default_conversion_rule:n #1{ +\cs_new_nopar:Npn \int_Alph_default_conversion_rule:n #1{ \if_case:w #1 \or: A\or: B\or: C\or: D\or: E\or: F \or: G\or: H\or: I\or: J\or: K\or: L @@ -159,15 +163,15 @@ \or: Y\or: Z \fi: } -\def_new:Npn \int_to_alph:n #1{ +\cs_new_nopar:Npn \int_to_alph:n #1{ \int_convert_number_with_rule:nnN {#1}{26} \int_alph_default_conversion_rule:n } -\def_new:Npn \int_to_Alph:n #1{ +\cs_new_nopar:Npn \int_to_Alph:n #1{ \int_convert_number_with_rule:nnN {#1}{26} \int_Alph_default_conversion_rule:n } -\def_new:Npn \int_to_symbol:n #1{ +\cs_new_nopar:Npn \int_to_symbol:n #1{ \mode_if_math:TF { \int_convert_number_with_rule:nnN {#1}{9} @@ -178,7 +182,7 @@ \int_symbol_text_conversion_rule:n } } -\def_new:Npn \int_symbol_math_conversion_rule:n #1 { +\cs_new_nopar:Npn \int_symbol_math_conversion_rule:n #1 { \if_case:w #1 \or: * \or: \dagger @@ -191,7 +195,7 @@ \or: \ddagger\ddagger \fi: } -\def_new:Npn \int_symbol_text_conversion_rule:n #1 { +\cs_new_nopar:Npn \int_symbol_text_conversion_rule:n #1 { \if_case:w #1 \or: \textasteriskcentered \or: \textdagger @@ -209,175 +213,139 @@ \int_new:N \l_tmpc_int \int_new:N \g_tmpa_int \int_new:N \g_tmpb_int -\int_new:N \l_loop_int % a variable for use in loops (whilenum etc) -\let_new:NN \int_eval:n \num_eval:n -\let_new:NN \int_eval:w \num_eval:w -\let_new:NN \int_eval_end: \num_eval_end: -\const_new:Nn \c_max_int {2147483647} -\def:Npn \int_pre_eval_one_arg:Nnn #1#2{\exp_args:No#1{\int_eval:w#2}} -\def:Npn \int_pre_eval_two_args:Nnn #1#2#3{ - \exp_args:Noo#1{\int_use:N\int_eval:w#2}{\int_use:N\int_eval:w#3} -} -\def_new:Npn \int_div_truncate:nn { - \int_pre_eval_two_args:Nnn\int_div_truncate_raw:nn -} -\def_new:Npn \int_div_truncate_raw:nn #1#2 { - \int_eval:w - \if_num:w \int_eval:w#1 = \c_zero - 0 - \else: - (#1 - \if_num:w \int_eval:w #1 < \c_zero - \if_num:w \int_eval:w#2 < \c_zero - -( #2 + - \else: - +( #2 - - \fi: - \else: - \if_num:w \int_eval:w #2 < \c_zero - +( #2 + - \else: - -( #2 - - \fi: - \fi: - 1)/2) - \fi: - /(#2) - \int_eval_end: -} -\def_new:Npn \int_div_round:nn { - \int_pre_eval_two_args:Nnn\int_div_round_raw:nn -} -\def_new:Npn \int_div_round_raw:nn #1#2 {\int_eval:n{#1/#2}} -\def_new:Npn \int_mod:nn {\int_pre_eval_two_args:Nnn\int_mod_raw:nn} -\def_new:Npn \int_mod_raw:nn #1#2 { - \int_eval:n{ #1 - \int_div_truncate_raw:nn {#1}{#2} * #2 } -} -\let_new:NN \int_compare:nNnTF \num_compare:nNnTF -\let_new:NN \int_compare:nNnT \num_compare:nNnT -\let_new:NN \int_compare:nNnF \num_compare:nNnF -\let_new:NN \int_max_of:nn \num_max_of:nn -\let_new:NN \int_min_of:nn \num_min_of:nn -\let_new:NN \int_abs:nn \num_abs:nn -\let_new:NN \int_compare_p:nNn \num_compare_p:nNn -\def_new:Npn \int_if_odd_p:n #1 { - \if_num_odd:w \int_eval:n{#1} - \c_true - \else: - \c_false - \fi: -} -\def_test_function_new:npn {int_if_odd:n}#1{\if_num_odd:w \int_eval:n{#1}} -\def_long_new:Npn \int_whiledo:nNnT #1#2#3#4{ - \int_compare:nNnT {#1}#2{#3}{#4 \int_whiledo:nNnT {#1}#2{#3}{#4}} -} -\def_long_new:Npn \int_whiledo:nNnF #1#2#3#4{ - \int_compare:nNnF {#1}#2{#3}{#4 \int_whiledo:nNnF {#1}#2{#3}{#4}} -} -\def_long_new:Npn \int_dowhile:nNnT #1#2#3#4{ - #4 \int_compare:nNnT {#1}#2{#3}{\int_dowhile:nNnT {#1}#2{#3}{#4}} -} -\def_long_new:Npn \int_dowhile:nNnF #1#2#3#4{ - #4 \int_compare:nNnF {#1}#2{#3}{\int_dowhile:nNnF {#1}#2{#3}{#4}} -} -\def_new:Npn \int_get_sign_and_digits:n #1{ - \int_get_sign_and_digits_aux:nNNN {#1} \c_true \c_true \c_true -} -\def_new:Npn \int_get_sign:n #1{ - \int_get_sign_and_digits_aux:nNNN {#1} \c_true \c_true \c_false -} -\def_new:Npn \int_get_digits:n #1{ - \int_get_sign_and_digits_aux:nNNN {#1} \c_true \c_false \c_true +\cs_set_nopar:Npn \int_pre_eval_one_arg:Nn #1#2{ + \exp_args:Nf#1{\intexpr_eval:n{#2}}} +\cs_set_nopar:Npn \int_pre_eval_two_args:Nnn #1#2#3{ + \exp_args:Nff#1{\intexpr_eval:n{#2}}{\intexpr_eval:n{#3}} +} +\cs_new_nopar:Npn \int_const:Nn #1#2 { + \intexpr_compare:nNnTF {#2} > \c_minus_one { + \intexpr_compare:nNnTF {#2} > \c_max_register_num { + \int_new:N #1 \int_set:Nn #1{#2} + } { + \chk_if_free_cs:N #1 \tex_mathchardef:D #1 = \intexpr_eval:n{#2} + } + } { + \int_new:N #1 \int_set:Nn #1{#2} + } } -\def_new:Npn \int_get_sign_and_digits_aux:nNNN #1#2#3#4{ - \tlist_if_head_eq_charcode:fNTF {#1} - + %% \tex_countdef:D \c_minus_one = 10 \scan_stop: + %% \c_minus_one = -1 \scan_stop: %% 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_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_thirteen {13} +\int_const:Nn \c_fourteen {14} +\int_const:Nn \c_fifteen {15} + %% \tex_chardef:D \c_sixteen = 16\scan_stop: %% in l3basics +\int_const:Nn \c_thirty_two {32} +\int_const:Nn \c_hundred_one {101} +\int_const:Nn \c_twohundred_fifty_five{255} +\int_const:Nn \c_twohundred_fifty_six {256} +\int_const:Nn \c_thousand {1000} +\int_const:Nn \c_ten_thousand {10000} +\int_const:Nn \c_ten_thousand_one {10001} +\int_const:Nn \c_ten_thousand_two {10002} +\int_const:Nn \c_ten_thousand_three {10003} +\int_const:Nn \c_ten_thousand_four {10004} +\int_const:Nn \c_twenty_thousand {20000} +\int_const:Nn \c_max_int {2147483647} +\cs_new_nopar:Npn \int_get_sign_and_digits:n #1{ + \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_true_bool \c_true_bool +} +\cs_new_nopar:Npn \int_get_sign:n #1{ + \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_true_bool \c_false_bool +} +\cs_new_nopar:Npn \int_get_digits:n #1{ + \int_get_sign_and_digits_aux:nNNN {#1} \c_true_bool \c_false_bool \c_true_bool +} +\cs_new_nopar:Npn \int_get_sign_and_digits_aux:nNNN #1#2#3#4{ + \tl_if_head_eq_charcode:fNTF {#1} - { \bool_if:NTF #2 - { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_false #3#4 } - { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_true #3#4 } + { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_false_bool #3#4 } + { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} \c_true_bool #3#4 } } { - \tlist_if_head_eq_charcode:fNTF {#1} + + \tl_if_head_eq_charcode:fNTF {#1} + { \int_get_sign_and_digits_aux:oNNN {\use_none:n #1} #2#3#4} { - \bool_double_if:NNnnnn #3#4 - { \bool_if:NF #2 - #1 } - { \bool_if:NF #2 - } - { #1 } { } + \bool_if:NT #3 { \bool_if:NF #2 - } + \bool_if:NT #4 {#1} } } } -\def_new:Npn \int_get_sign_and_digits_aux:oNNN{ - \exp_args:No\int_get_sign_and_digits_aux:nNNN -} -\def:Npn \int_convert_from_base_ten:nn#1#2{ - \num_compare:nNnTF {#1}<\c_zero +\cs_generate_variant:Nn \int_get_sign_and_digits_aux:nNNN {oNNN} +\cs_set_nopar:Npn \int_convert_from_base_ten:nn#1#2{ + \intexpr_compare:nNnTF {#1}<\c_zero { - - \int_convert_from_base_ten_aux:non {} - { \int_use:N \int_eval:n {-#1} } + - \int_convert_from_base_ten_aux:nfn {} + { \intexpr_eval:n {-#1} } } { - \int_convert_from_base_ten_aux:non {} - { \int_use:N \int_eval:n {#1} } + \int_convert_from_base_ten_aux:nfn {} + { \intexpr_eval:n {#1} } } {#2} } -\def_new:Npn \int_convert_from_base_ten_aux:nnn#1#2#3{ - \num_compare:nNnTF {#2}<{#3} +\cs_new_nopar:Npn \int_convert_from_base_ten_aux:nnn#1#2#3{ + \intexpr_compare:nNnTF {#2}<{#3} { \int_convert_number_to_letter:n{#2} #1 } { - \int_convert_from_base_ten_aux:fon + \int_convert_from_base_ten_aux:ffn { - \int_convert_number_to_letter:n {\int_use:N\int_mod_raw:nn {#2}{#3}} + \int_convert_number_to_letter:n {\intexpr_mod:nn {#2}{#3}} #1 } - {\int_use:N \int_div_truncate_raw:nn{#2}{#3}} + { \intexpr_div_truncate:nn{#2}{#3}} {#3} } } -\def:Npn \int_convert_from_base_ten_aux:non{ - \exp_args:Nno\int_convert_from_base_ten_aux:nnn -} -\def:Npn \int_convert_from_base_ten_aux:fon{ - \exp_args:Nfo\int_convert_from_base_ten_aux:nnn -} -\def:Npn \int_convert_number_to_letter:n #1{ \if_case:w \int_eval:w - #1-10\scan_stop: \exp_after:NN A \or: \exp_after:NN B \or: - \exp_after:NN C \or: \exp_after:NN D \or: \exp_after:NN E \or: - \exp_after:NN F \or: \exp_after:NN G \or: \exp_after:NN H \or: - \exp_after:NN I \or: \exp_after:NN J \or: \exp_after:NN K \or: - \exp_after:NN L \or: \exp_after:NN M \or: \exp_after:NN N \or: - \exp_after:NN O \or: \exp_after:NN P \or: \exp_after:NN Q \or: - \exp_after:NN R \or: \exp_after:NN S \or: \exp_after:NN T \or: - \exp_after:NN U \or: \exp_after:NN V \or: \exp_after:NN W \or: - \exp_after:NN X \or: \exp_after:NN Y \or: \exp_after:NN Z \else: - \use_arg_i_after_fi:nw{ #1 }\fi: } -\def:Npn \int_convert_to_base_ten:nn #1#2 { - \int_use:N\int_eval:n{ +\cs_generate_variant:Nn \int_convert_from_base_ten_aux:nnn {nfn} +\cs_generate_variant:Nn \int_convert_from_base_ten_aux:nnn {ffn} +\cs_set_nopar:Npn \int_convert_number_to_letter:n #1{ + \if_case:w \intexpr_eval:w #1-10\intexpr_eval_end: + \exp_after:wN A \or: \exp_after:wN B \or: + \exp_after:wN C \or: \exp_after:wN D \or: \exp_after:wN E \or: + \exp_after:wN F \or: \exp_after:wN G \or: \exp_after:wN H \or: + \exp_after:wN I \or: \exp_after:wN J \or: \exp_after:wN K \or: + \exp_after:wN L \or: \exp_after:wN M \or: \exp_after:wN N \or: + \exp_after:wN O \or: \exp_after:wN P \or: \exp_after:wN Q \or: + \exp_after:wN R \or: \exp_after:wN S \or: \exp_after:wN T \or: + \exp_after:wN U \or: \exp_after:wN V \or: \exp_after:wN W \or: + \exp_after:wN X \or: \exp_after:wN Y \or: \exp_after:wN Z \else: + \use_i_after_fi:nw{ #1 }\fi: } +\cs_set_nopar:Npn \int_convert_to_base_ten:nn #1#2 { + \intexpr_eval:n{ \int_get_sign:n{#1} \exp_args:Nf\int_convert_to_base_ten_aux:nn {\int_get_digits:n{#1}}{#2} } } -\def_new:Npn \int_convert_to_base_ten_aux:nn #1#2{ +\cs_new_nopar:Npn \int_convert_to_base_ten_aux:nn #1#2{ \int_convert_to_base_ten_auxi:nnN {0}{#2} #1 \q_nil } -\def_new:Npn \int_convert_to_base_ten_auxi:nnN#1#2#3{ +\cs_new_nopar:Npn \int_convert_to_base_ten_auxi:nnN#1#2#3{ \quark_if_nil:NTF #3 {#1} - {\exp_args:No\int_convert_to_base_ten_auxi:nnN - {\int_use:N \int_eval:n{ #1*#2+\int_convert_letter_to_number:N #3} } + {\exp_args:Nf\int_convert_to_base_ten_auxi:nnN + {\intexpr_eval:n{ #1*#2+\int_convert_letter_to_number:N #3} } {#2} } } -\def:Npn \int_convert_letter_to_number:N #1{ - \int_compare:nNnTF{`#1}<{58}{#1} +\cs_set_nopar:Npn \int_convert_letter_to_number:N #1{ + \intexpr_compare:nNnTF{`#1}<{58}{#1} { - \int_eval:n{ `#1 - - \if:w\int_compare_p:nNn{`#1}<{91} - 55 - \else: - 87 - \fi: + \intexpr_eval:n{ `#1 - + \intexpr_compare:nNnTF{`#1}<{91}{ 55 }{ 87 } } } } |