summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3kernel/l3int.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-07-23 17:15:00 +0000
committerKarl Berry <karl@freefriends.org>2012-07-23 17:15:00 +0000
commit134349701bddf7cbbacf6030c6b9f9838aff96fa (patch)
treeec1140c46e1c0347a671a6fa3cf8af5a79e95f93 /Master/texmf-dist/tex/latex/l3kernel/l3int.sty
parentf7855c12c18bb97b7b9e49ab685ee558d8c0b47b (diff)
l3kernel 3990 (17jul12)
git-svn-id: svn://tug.org/texlive/trunk@27108 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3int.sty')
-rw-r--r--Master/texmf-dist/tex/latex/l3kernel/l3int.sty433
1 files changed, 249 insertions, 184 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3int.sty b/Master/texmf-dist/tex/latex/l3kernel/l3int.sty
index 76b61a861c6..f33a864bff7 100644
--- a/Master/texmf-dist/tex/latex/l3kernel/l3int.sty
+++ b/Master/texmf-dist/tex/latex/l3kernel/l3int.sty
@@ -46,57 +46,56 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3int.dtx 3490 2012-03-04 01:00:53Z bruno $
- {L3 Experimental integers}
+\GetIdInfo$Id: l3int.dtx 3986 2012-07-15 19:23:51Z joseph $
+ {L3 Integers}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
-\package_check_loaded_expl:
-\cs_new_eq:NN \int_value:w \tex_number:D
-\cs_new_eq:NN \int_eval:w \etex_numexpr:D
-\cs_new_eq:NN \int_eval_end: \tex_relax:D
-\cs_new_eq:NN \if_num:w \tex_ifnum:D
-\cs_new_eq:NN \if_int_odd:w \tex_ifodd:D
-\cs_new_eq:NN \if_case:w \tex_ifcase:D
-\cs_new:Npn \int_eval:n #1 { \int_value:w \int_eval:w #1 \int_eval_end: }
+\__expl_package_check:
+\cs_new_eq:NN \__int_value:w \tex_number:D
+\cs_new_eq:NN \__int_eval:w \etex_numexpr:D
+\cs_new_eq:NN \__int_eval_end: \tex_relax:D
+\cs_new_eq:NN \if_int_odd:w \tex_ifodd:D
+\cs_new_eq:NN \if_case:w \tex_ifcase:D
+\cs_new:Npn \int_eval:n #1 { \__int_value:w \__int_eval:w #1 \__int_eval_end: }
\cs_new:Npn \int_abs:n #1
{
- \int_value:w
- \if_int_compare:w \int_eval:w #1 < \c_zero
+ \__int_value:w
+ \if_int_compare:w \__int_eval:w #1 < \c_zero
-
\fi:
- \int_eval:w #1 \int_eval_end:
+ \__int_eval:w #1 \__int_eval_end:
}
\cs_new:Npn \int_max:nn #1#2
{
- \int_value:w \int_eval:w
+ \__int_value:w \__int_eval:w
\if_int_compare:w
- \int_eval:w #1 > \int_eval:w #2 \int_eval_end:
+ \__int_eval:w #1 > \__int_eval:w #2 \__int_eval_end:
#1
\else:
#2
\fi:
- \int_eval_end:
+ \__int_eval_end:
}
\cs_new:Npn \int_min:nn #1#2
{
- \int_value:w \int_eval:w
+ \__int_value:w \__int_eval:w
\if_int_compare:w
- \int_eval:w #1 < \int_eval:w #2 \int_eval_end:
+ \__int_eval:w #1 < \__int_eval:w #2 \__int_eval_end:
#1
\else:
#2
\fi:
- \int_eval_end:
+ \__int_eval_end:
}
\cs_new:Npn \int_div_truncate:nn #1#2
{
- \int_use:N \int_eval:w
- \exp_after:wN \int_div_truncate_aux:NwNw
- \int_use:N \int_eval:w #1 \exp_after:wN ;
- \int_use:N \int_eval:w #2 ;
- \int_eval_end:
+ \int_use:N \__int_eval:w
+ \exp_after:wN \__int_div_truncate:NwNw
+ \int_use:N \__int_eval:w #1 \exp_after:wN ;
+ \int_use:N \__int_eval:w #2 ;
+ \__int_eval_end:
}
-\cs_new:Npn \int_div_truncate_aux:NwNw #1#2; #3#4;
+\cs_new:Npn \__int_div_truncate:NwNw #1#2; #3#4;
{
\if_meaning:w 0 #1
\c_zero
@@ -112,13 +111,13 @@
\cs_new:Npn \int_div_round:nn #1#2 { \int_eval:n { ( #1 ) / ( #2 ) } }
\cs_new:Npn \int_mod:nn #1#2
{
- \int_value:w \int_eval:w
+ \__int_value:w \__int_eval:w
#1 - \int_div_truncate:nn {#1} {#2} * ( #2 )
- \int_eval_end:
+ \__int_eval_end:
}
\cs_new_protected:Npn \int_new:N #1
{
- \chk_if_free_cs:N #1
+ \__chk_if_free_cs:N #1
\newcount #1
}
\cs_generate_variant:Nn \int_new:N { c }
@@ -126,15 +125,15 @@
{
\int_compare:nNnTF {#2} > \c_minus_one
{
- \int_compare:nNnTF {#2} > \c_max_const_int
+ \int_compare:nNnTF {#2} > \c__max_constdef_int
{
\int_new:N #1
\int_gset:Nn #1 {#2}
}
{
- \chk_if_free_cs:N #1
- \tex_global:D \int_constdef:Nw #1 =
- \int_eval:w #2 \int_eval_end:
+ \__chk_if_free_cs:N #1
+ \tex_global:D \__int_constdef:Nw #1 =
+ \__int_eval:w #2 \__int_eval_end:
}
}
{
@@ -145,12 +144,12 @@
\cs_generate_variant:Nn \int_const:Nn { c }
\pdftex_if_engine:TF
{
- \cs_new_eq:NN \int_constdef:Nw \tex_mathchardef:D
- \tex_mathchardef:D \c_max_const_int 32 767 ~
+ \cs_new_eq:NN \__int_constdef:Nw \tex_mathchardef:D
+ \tex_mathchardef:D \c__max_constdef_int 32 767 ~
}
{
- \cs_new_eq:NN \int_constdef:Nw \tex_chardef:D
- \tex_chardef:D \c_max_const_int 1 114 111 ~
+ \cs_new_eq:NN \__int_constdef:Nw \tex_chardef:D
+ \tex_chardef:D \c__max_constdef_int 1 114 111 ~
}
\cs_new_protected:Npn \int_zero:N #1 { #1 = \c_zero }
\cs_new_protected:Npn \int_gzero:N #1 { \tex_global:D #1 = \c_zero }
@@ -177,9 +176,9 @@
\cs_new_eq:NN \int_if_exist:cF \cs_if_exist:cF
\cs_new_eq:NN \int_if_exist_p:c \cs_if_exist_p:c
\cs_new_protected:Npn \int_add:Nn #1#2
- { \tex_advance:D #1 by \int_eval:w #2 \int_eval_end: }
+ { \tex_advance:D #1 by \__int_eval:w #2 \__int_eval_end: }
\cs_new_protected:Npn \int_sub:Nn #1#2
- { \tex_advance:D #1 by - \int_eval:w #2 \int_eval_end: }
+ { \tex_advance:D #1 by - \__int_eval:w #2 \__int_eval_end: }
\cs_new_protected_nopar:Npn \int_gadd:Nn
{ \tex_global:D \int_add:Nn }
\cs_new_protected_nopar:Npn \int_gsub:Nn
@@ -201,70 +200,84 @@
\cs_generate_variant:Nn \int_gincr:N { c }
\cs_generate_variant:Nn \int_gdecr:N { c }
\cs_new_protected:Npn \int_set:Nn #1#2
- { #1 ~ \int_eval:w #2\int_eval_end: }
+ { #1 ~ \__int_eval:w #2\__int_eval_end: }
\cs_new_protected_nopar:Npn \int_gset:Nn { \tex_global:D \int_set:Nn }
\cs_generate_variant:Nn \int_set:Nn { c }
\cs_generate_variant:Nn \int_gset:Nn { c }
\cs_new_eq:NN \int_use:N \tex_the:D
\cs_new:Npn \int_use:c #1 { \int_use:N \cs:w #1 \cs_end: }
-\cs_new_protected_nopar:Npn \kernel_compare_error:
+\cs_new_protected_nopar:Npn \__prg_compare_error:
{
- \if_num:w \c_zero \c_zero \fi:
+ \if_int_compare:w \c_zero \c_zero \fi:
=
- \kernel_compare_error:
+ \__prg_compare_error:
}
-\cs_new:Npn \kernel_compare_error:Nw
+\cs_new:Npn \__prg_compare_error:Nw
#1#2 \prg_return_true: \else: \prg_return_false: \fi:
{
- \msg_expandable_kernel_error:nnn
+ \__msg_kernel_expandable_error:nnn
{ kernel } { unknown-comparison } {#1}
\prg_return_false:
}
\prg_new_conditional:Npnn \int_compare:n #1 { p , T , F , TF }
{
- \exp_after:wN \int_compare_aux:Nw \int_use:N \int_eval:w #1
- \kernel_compare_error: \int_eval_end:
+ \exp_after:wN \__int_compare_aux:Nw \int_use:N \__int_eval:w #1
+ \__prg_compare_error: \__int_eval_end:
\prg_return_true:
\else:
\prg_return_false:
\fi:
}
-\cs_new:Npn \int_compare_aux:Nw #1#2 \kernel_compare_error:
+\cs_new:Npn \__int_compare_aux:Nw #1#2 \__prg_compare_error:
{
- \exp_after:wN \int_compare_aux:NNw
- \int_to_roman:w - 0 #2 ?? \q_mark
+ \exp_after:wN \__int_compare_aux:NNw
+ \__int_to_roman:w - 0 #2 ?? \q_mark
#1#2
}
-\cs_new:Npn \int_compare_aux:NNw #1#2#3 \q_mark
- {
- \use:c { int_compare_ #1 \if_meaning:w = #2 = \fi: :NNw }
- \kernel_compare_error:Nw #1
- }
-\cs_new:cpn { int_compare_=:NNw } #1#2#3 =
- { \if_int_compare:w #3 = \int_eval:w }
-\cs_new:cpn { int_compare_<:NNw } #1#2#3 <
- { \if_int_compare:w #3 < \int_eval:w }
-\cs_new:cpn { int_compare_>:NNw } #1#2#3 >
- { \if_int_compare:w #3 > \int_eval:w }
-\cs_new:cpn { int_compare_==:NNw } #1#2#3 ==
- { \if_int_compare:w #3 = \int_eval:w }
-\cs_new:cpn { int_compare_!=:NNw } #1#2#3 !=
- { \reverse_if:N \if_int_compare:w #3 = \int_eval:w }
-\cs_new:cpn { int_compare_<=:NNw } #1#2#3 <=
- { \reverse_if:N \if_int_compare:w #3 > \int_eval:w }
-\cs_new:cpn { int_compare_>=:NNw } #1#2#3 >=
- { \reverse_if:N \if_int_compare:w #3 < \int_eval:w }
-\prg_new_conditional:Npnn \int_compare:nNn #1#2#3 { p , T , F , TF}
- {
- \if_int_compare:w \int_eval:w #1 #2 \int_eval:w #3 \int_eval_end:
+\cs_new:Npn \__int_compare_aux:NNw #1#2#3 \q_mark
+ {
+ \use:c { __int_compare_ #1 \if_meaning:w = #2 = \fi: :NNw }
+ \__prg_compare_error:Nw #1
+ }
+\cs_new:cpn { __int_compare_=:NNw } #1#2#3 =
+ { \if_int_compare:w #3 = \__int_eval:w }
+\cs_new:cpn { __int_compare_<:NNw } #1#2#3 <
+ { \if_int_compare:w #3 < \__int_eval:w }
+\cs_new:cpn { __int_compare_>:NNw } #1#2#3 >
+ { \if_int_compare:w #3 > \__int_eval:w }
+\cs_new:cpn { __int_compare_==:NNw } #1#2#3 ==
+ { \if_int_compare:w #3 = \__int_eval:w }
+\cs_new:cpn { __int_compare_!=:NNw } #1#2#3 !=
+ { \reverse_if:N \if_int_compare:w #3 = \__int_eval:w }
+\cs_new:cpn { __int_compare_<=:NNw } #1#2#3 <=
+ { \reverse_if:N \if_int_compare:w #3 > \__int_eval:w }
+\cs_new:cpn { __int_compare_>=:NNw } #1#2#3 >=
+ { \reverse_if:N \if_int_compare:w #3 < \__int_eval:w }
+\prg_new_conditional:Npnn \int_compare:nNn #1#2#3 { p , T , F , TF }
+ {
+ \if_int_compare:w \__int_eval:w #1 #2 \__int_eval:w #3 \__int_eval_end:
\prg_return_true:
\else:
\prg_return_false:
\fi:
}
+\cs_new:Npn \int_case:nnn #1
+ {
+ \tex_romannumeral:D
+ \exp_args:Nf \__int_case:nnn { \int_eval:n {#1} }
+ }
+\cs_new:Npn \__int_case:nnn #1#2#3
+ { \__int_case:nw {#1} #2 {#1} {#3} \q_recursion_stop }
+\cs_new:Npn \__int_case:nw #1#2#3
+ {
+ \int_compare:nNnTF {#1} = {#2}
+ { \__int_case_end:nw {#3} }
+ { \__int_case:nw {#1} }
+ }
+\cs_new_eq:NN \__int_case_end:nw \__prg_case_end:nw
\prg_new_conditional:Npnn \int_if_odd:n #1 { p , T , F , TF}
{
- \if_int_odd:w \int_eval:w #1 \int_eval_end:
+ \if_int_odd:w \__int_eval:w #1 \__int_eval_end:
\prg_return_true:
\else:
\prg_return_false:
@@ -272,7 +285,7 @@
}
\prg_new_conditional:Npnn \int_if_even:n #1 { p , T , F , TF}
{
- \if_int_odd:w \int_eval:w #1 \int_eval_end:
+ \if_int_odd:w \__int_eval:w #1 \__int_eval_end:
\prg_return_false:
\else:
\prg_return_true:
@@ -334,22 +347,70 @@
\int_compare:nNnF {#1} #2 {#3}
{ \int_do_until:nNnn {#1} #2 {#3} {#4} }
}
+\cs_new:Npn \int_step_function:nnnN #1#2#3#4
+ {
+ \int_compare:nNnTF {#2} > \c_zero
+ { \exp_args:NNf \__int_step:NnnnN > }
+ {
+ \int_compare:nNnTF {#2} = \c_zero
+ {
+ \__msg_kernel_expandable_error:nnn { kernel } { zero-step } {#4}
+ \use_none:nnnn
+ }
+ { \exp_args:NNf \__int_step:NnnnN < }
+ }
+ { \int_eval:n {#1} } {#2} {#3} #4
+ }
+\cs_new:Npn \__int_step:NnnnN #1#2#3#4#5
+ {
+ \int_compare:nNnF {#2} #1 {#4}
+ {
+ #5 {#2}
+ \exp_args:NNf \__int_step:NnnnN
+ #1 { \int_eval:n { #2 + #3 } } {#3} {#4} #5
+ }
+ }
+\cs_new_protected_nopar:Npn \int_step_inline:nnnn
+ {
+ \int_gincr:N \g__prg_map_int
+ \exp_args:NNc \__int_step:NNnnnn
+ \cs_gset_nopar:Npn
+ { __prg_map_ \int_use:N \g__prg_map_int :w }
+ }
+\cs_new_protected:Npn \int_step_variable:nnnNn #1#2#3#4#5
+ {
+ \int_gincr:N \g__prg_map_int
+ \exp_args:NNc \__int_step:NNnnnn
+ \cs_gset_nopar:Npx
+ { __prg_map_ \int_use:N \g__prg_map_int :w }
+ {#1}{#2}{#3}
+ {
+ \tl_set:Nn \exp_not:N #4 {##1}
+ \exp_not:n {#5}
+ }
+ }
+\cs_new_protected:Npn \__int_step:NNnnnn #1#2#3#4#5#6
+ {
+ #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 }
+ }
\cs_new:Npn \int_to_arabic:n #1 { \int_eval:n {#1} }
\cs_new:Npn \int_to_symbols:nnn #1#2#3
{
\int_compare:nNnTF {#1} > {#2}
{
- \exp_args:NNo \exp_args:No \int_to_symbols_aux:nnnn
+ \exp_args:NNo \exp_args:No \__int_to_symbols:nnnn
{
- \prg_case_int:nnn
+ \int_case:nnn
{ 1 + \int_mod:nn { #1 - 1 } {#2} }
{#3} { }
}
{#1} {#2} {#3}
}
- { \prg_case_int:nnn {#1} {#3} { } }
+ { \int_case:nnn {#1} {#3} { } }
}
-\cs_new:Npn \int_to_symbols_aux:nnnn #1#2#3#4
+\cs_new:Npn \__int_to_symbols:nnnn #1#2#3#4
{
\exp_args:Nf \int_to_symbols:nnn
{ \int_div_truncate:nn { #2 - 1 } {#3} } {#3} {#4}
@@ -420,37 +481,37 @@
}
}
\cs_new:Npn \int_to_base:nn #1
- { \exp_args:Nf \int_to_base_aux_i:nn { \int_eval:n {#1} } }
-\cs_new:Npn \int_to_base_aux_i:nn #1#2
+ { \exp_args:Nf \__int_to_base:nn { \int_eval:n {#1} } }
+\cs_new:Npn \__int_to_base:nn #1#2
{
\int_compare:nNnTF {#1} < \c_zero
- { \exp_args:No \int_to_base_aux_ii:nnN { \use_none:n #1 } {#2} - }
- { \int_to_base_aux_ii:nnN {#1} {#2} \c_empty_tl }
+ { \exp_args:No \__int_to_base:nnN { \use_none:n #1 } {#2} - }
+ { \__int_to_base:nnN {#1} {#2} \c_empty_tl }
}
-\cs_new:Npn \int_to_base_aux_ii:nnN #1#2#3
+\cs_new:Npn \__int_to_base:nnN #1#2#3
{
\int_compare:nNnTF {#1} < {#2}
- { \exp_last_unbraced:Nf #3 { \int_to_letter:n {#1} } }
+ { \exp_last_unbraced:Nf #3 { \__int_to_letter:n {#1} } }
{
- \exp_args:Nf \int_to_base_aux_iii:nnnN
- { \int_to_letter:n { \int_mod:nn {#1} {#2} } }
+ \exp_args:Nf \__int_to_base:nnnN
+ { \__int_to_letter:n { \int_mod:nn {#1} {#2} } }
{#1}
{#2}
#3
}
}
-\cs_new:Npn \int_to_base_aux_iii:nnnN #1#2#3#4
+\cs_new:Npn \__int_to_base:nnnN #1#2#3#4
{
- \exp_args:Nf \int_to_base_aux_ii:nnN
+ \exp_args:Nf \__int_to_base:nnN
{ \int_div_truncate:nn {#2} {#3} }
{#3}
#4
#1
}
-\cs_new:Npn \int_to_letter:n #1
+\cs_new:Npn \__int_to_letter:n #1
{
\exp_after:wN \exp_after:wN
- \if_case:w \int_eval:w #1 - \c_ten \int_eval_end:
+ \if_case:w \__int_eval:w #1 - \c_ten \__int_eval_end:
A
\or: B
\or: C
@@ -477,7 +538,7 @@
\or: X
\or: Y
\or: Z
- \else: \int_value:w \int_eval:w #1 \exp_after:wN \int_eval_end:
+ \else: \__int_value:w \__int_eval:w #1 \exp_after:wN \__int_eval_end:
\fi:
}
\cs_new:Npn \int_to_binary:n #1
@@ -488,117 +549,117 @@
{ \int_to_base:nn {#1} { 8 } }
\cs_new:Npn \int_to_roman:n #1
{
- \exp_after:wN \int_to_roman_aux:N
- \int_to_roman:w \int_eval:n {#1} Q
+ \exp_after:wN \__int_to_roman:N
+ \__int_to_roman:w \int_eval:n {#1} Q
}
-\cs_new:Npn \int_to_roman_aux:N #1
+\cs_new:Npn \__int_to_roman:N #1
{
- \use:c { int_to_roman_ #1 :w }
- \int_to_roman_aux:N
+ \use:c { __int_to_roman_ #1 :w }
+ \__int_to_roman:N
}
\cs_new:Npn \int_to_Roman:n #1
{
- \exp_after:wN \int_to_Roman_aux:N
- \int_to_roman:w \int_eval:n {#1} Q
- }
-\cs_new:Npn \int_to_Roman_aux:N #1
- {
- \use:c { int_to_Roman_ #1 :w }
- \int_to_Roman_aux:N
- }
-\cs_new_nopar:Npn \int_to_roman_i:w { i }
-\cs_new_nopar:Npn \int_to_roman_v:w { v }
-\cs_new_nopar:Npn \int_to_roman_x:w { x }
-\cs_new_nopar:Npn \int_to_roman_l:w { l }
-\cs_new_nopar:Npn \int_to_roman_c:w { c }
-\cs_new_nopar:Npn \int_to_roman_d:w { d }
-\cs_new_nopar:Npn \int_to_roman_m:w { m }
-\cs_new_nopar:Npn \int_to_roman_Q:w #1 { }
-\cs_new_nopar:Npn \int_to_Roman_i:w { I }
-\cs_new_nopar:Npn \int_to_Roman_v:w { V }
-\cs_new_nopar:Npn \int_to_Roman_x:w { X }
-\cs_new_nopar:Npn \int_to_Roman_l:w { L }
-\cs_new_nopar:Npn \int_to_Roman_c:w { C }
-\cs_new_nopar:Npn \int_to_Roman_d:w { D }
-\cs_new_nopar:Npn \int_to_Roman_m:w { M }
-\cs_new:Npn \int_to_Roman_Q:w #1 { }
-\cs_new:Npn \int_get_sign:n #1
- {
- \int_get_sign_and_digits_aux:nNNN {#1}
+ \exp_after:wN \__int_to_Roman_aux:N
+ \__int_to_roman:w \int_eval:n {#1} Q
+ }
+\cs_new:Npn \__int_to_Roman_aux:N #1
+ {
+ \use:c { __int_to_Roman_ #1 :w }
+ \__int_to_Roman_aux:N
+ }
+\cs_new_nopar:Npn \__int_to_roman_i:w { i }
+\cs_new_nopar:Npn \__int_to_roman_v:w { v }
+\cs_new_nopar:Npn \__int_to_roman_x:w { x }
+\cs_new_nopar:Npn \__int_to_roman_l:w { l }
+\cs_new_nopar:Npn \__int_to_roman_c:w { c }
+\cs_new_nopar:Npn \__int_to_roman_d:w { d }
+\cs_new_nopar:Npn \__int_to_roman_m:w { m }
+\cs_new_nopar:Npn \__int_to_roman_Q:w #1 { }
+\cs_new_nopar:Npn \__int_to_Roman_i:w { I }
+\cs_new_nopar:Npn \__int_to_Roman_v:w { V }
+\cs_new_nopar:Npn \__int_to_Roman_x:w { X }
+\cs_new_nopar:Npn \__int_to_Roman_l:w { L }
+\cs_new_nopar:Npn \__int_to_Roman_c:w { C }
+\cs_new_nopar:Npn \__int_to_Roman_d:w { D }
+\cs_new_nopar:Npn \__int_to_Roman_m:w { M }
+\cs_new:Npn \__int_to_Roman_Q:w #1 { }
+\cs_new:Npn \__int_get_sign:n #1
+ {
+ \__int_get_sign_and_digits:nNNN {#1}
\c_true_bool \c_true_bool \c_false_bool
}
-\cs_new:Npn \int_get_digits:n #1
+\cs_new:Npn \__int_get_digits:n #1
{
- \int_get_sign_and_digits_aux:nNNN {#1}
+ \__int_get_sign_and_digits:nNNN {#1}
\c_true_bool \c_false_bool \c_true_bool
}
-\cs_new:Npn \int_get_sign_and_digits_aux:nNNN #1#2#3#4
+\cs_new:Npn \__int_get_sign_and_digits:nNNN #1#2#3#4
{
\exp_args:Nf \tl_if_head_eq_charcode:nNTF {#1} -
{
\bool_if:NTF #2
{
- \int_get_sign_and_digits_aux:oNNN
+ \__int_get_sign_and_digits:oNNN
{ \use_none:n #1 } \c_false_bool #3#4
}
{
- \int_get_sign_and_digits_aux:oNNN
+ \__int_get_sign_and_digits:oNNN
{ \use_none:n #1 } \c_true_bool #3#4
}
}
{
\exp_args:Nf \tl_if_head_eq_charcode:nNTF {#1} +
- { \int_get_sign_and_digits_aux:oNNN { \use_none:n #1 } #2#3#4 }
+ { \__int_get_sign_and_digits:oNNN { \use_none:n #1 } #2#3#4 }
{
\bool_if:NT #3 { \bool_if:NF #2 - }
\bool_if:NT #4 {#1}
}
}
}
-\cs_generate_variant:Nn \int_get_sign_and_digits_aux:nNNN { o }
+\cs_generate_variant:Nn \__int_get_sign_and_digits:nNNN { o }
\cs_new:Npn \int_from_alph:n #1
{
\int_eval:n
{
- \int_get_sign:n {#1}
- \exp_args:Nf \int_from_alph_aux:n { \int_get_digits:n {#1} }
+ \__int_get_sign:n {#1}
+ \exp_args:Nf \__int_from_alph:n { \__int_get_digits:n {#1} }
}
}
-\cs_new:Npn \int_from_alph_aux:n #1
- { \int_from_alph_aux:nN { 0 } #1 \q_nil }
-\cs_new:Npn \int_from_alph_aux:nN #1#2
+\cs_new:Npn \__int_from_alph:n #1
+ { \__int_from_alph:nN { 0 } #1 \q_nil }
+\cs_new:Npn \__int_from_alph:nN #1#2
{
\quark_if_nil:NTF #2
{#1}
{
- \exp_args:Nf \int_from_alph_aux:nN
- { \int_eval:n { #1 * 26 + \int_from_alph_aux:N #2 } }
+ \exp_args:Nf \__int_from_alph:nN
+ { \int_eval:n { #1 * 26 + \__int_from_alph:N #2 } }
}
}
-\cs_new:Npn \int_from_alph_aux:N #1
+\cs_new:Npn \__int_from_alph:N #1
{ \int_eval:n { `#1 - \int_compare:nNnTF { `#1 } < { 91 } { 64 } { 96 } } }
\cs_new:Npn \int_from_base:nn #1#2
{
\int_eval:n
{
- \int_get_sign:n {#1}
- \exp_args:Nf \int_from_base_aux:nn
- { \int_get_digits:n {#1} } {#2}
+ \__int_get_sign:n {#1}
+ \exp_args:Nf \__int_from_base:nn
+ { \__int_get_digits:n {#1} } {#2}
}
}
-\cs_new:Npn \int_from_base_aux:nn #1#2
- { \int_from_base_aux:nnN { 0 } { #2 } #1 \q_nil }
-\cs_new:Npn \int_from_base_aux:nnN #1#2#3
+\cs_new:Npn \__int_from_base:nn #1#2
+ { \__int_from_base:nnN { 0 } { #2 } #1 \q_nil }
+\cs_new:Npn \__int_from_base:nnN #1#2#3
{
\quark_if_nil:NTF #3
{#1}
{
- \exp_args:Nf \int_from_base_aux:nnN
- { \int_eval:n { #1 * #2 + \int_from_base_aux:N #3 } }
+ \exp_args:Nf \__int_from_base:nnN
+ { \int_eval:n { #1 * #2 + \__int_from_base:N #3 } }
{#2}
}
}
-\cs_new:Npn \int_from_base_aux:N #1
+\cs_new:Npn \__int_from_base:N #1
{
\int_compare:nNnTF { `#1 } < { 58 }
{#1}
@@ -613,70 +674,70 @@
{ \int_from_base:nn {#1} \c_sixteen }
\cs_new:Npn \int_from_octal:n #1
{ \int_from_base:nn {#1} \c_eight }
-\int_const:cn { c_int_from_roman_i_int } { 1 }
-\int_const:cn { c_int_from_roman_v_int } { 5 }
-\int_const:cn { c_int_from_roman_x_int } { 10 }
-\int_const:cn { c_int_from_roman_l_int } { 50 }
-\int_const:cn { c_int_from_roman_c_int } { 100 }
-\int_const:cn { c_int_from_roman_d_int } { 500 }
-\int_const:cn { c_int_from_roman_m_int } { 1000 }
-\int_const:cn { c_int_from_roman_I_int } { 1 }
-\int_const:cn { c_int_from_roman_V_int } { 5 }
-\int_const:cn { c_int_from_roman_X_int } { 10 }
-\int_const:cn { c_int_from_roman_L_int } { 50 }
-\int_const:cn { c_int_from_roman_C_int } { 100 }
-\int_const:cn { c_int_from_roman_D_int } { 500 }
-\int_const:cn { c_int_from_roman_M_int } { 1000 }
+\int_const:cn { c__int_from_roman_i_int } { 1 }
+\int_const:cn { c__int_from_roman_v_int } { 5 }
+\int_const:cn { c__int_from_roman_x_int } { 10 }
+\int_const:cn { c__int_from_roman_l_int } { 50 }
+\int_const:cn { c__int_from_roman_c_int } { 100 }
+\int_const:cn { c__int_from_roman_d_int } { 500 }
+\int_const:cn { c__int_from_roman_m_int } { 1000 }
+\int_const:cn { c__int_from_roman_I_int } { 1 }
+\int_const:cn { c__int_from_roman_V_int } { 5 }
+\int_const:cn { c__int_from_roman_X_int } { 10 }
+\int_const:cn { c__int_from_roman_L_int } { 50 }
+\int_const:cn { c__int_from_roman_C_int } { 100 }
+\int_const:cn { c__int_from_roman_D_int } { 500 }
+\int_const:cn { c__int_from_roman_M_int } { 1000 }
\cs_new:Npn \int_from_roman:n #1
{
\tl_if_blank:nF {#1}
{
- \exp_after:wN \int_from_roman_end:w
- \int_value:w \int_eval:w
- \int_from_roman_aux:NN #1 Q \q_stop
+ \exp_after:wN \__int_from_roman_end:w
+ \__int_value:w \__int_eval:w
+ \__int_from_roman:NN #1 Q \q_stop
}
}
-\cs_new:Npn \int_from_roman_aux:NN #1#2
+\cs_new:Npn \__int_from_roman:NN #1#2
{
\str_if_eq:nnTF {#1} { Q }
{#1#2}
{
\str_if_eq:nnTF {#2} { Q }
{
- \int_if_exist:cF { c_int_from_roman_ #1 _int }
- { \int_from_roman_clean_up:w }
+ \int_if_exist:cF { c__int_from_roman_ #1 _int }
+ { \__int_from_roman_clean_up:w }
+
- \use:c { c_int_from_roman_ #1 _int }
+ \use:c { c__int_from_roman_ #1 _int }
#2
}
{
- \int_if_exist:cF { c_int_from_roman_ #1 _int }
- { \int_from_roman_clean_up:w }
- \int_if_exist:cF { c_int_from_roman_ #2 _int }
- { \int_from_roman_clean_up:w }
+ \int_if_exist:cF { c__int_from_roman_ #1 _int }
+ { \__int_from_roman_clean_up:w }
+ \int_if_exist:cF { c__int_from_roman_ #2 _int }
+ { \__int_from_roman_clean_up:w }
\int_compare:nNnTF
- { \use:c { c_int_from_roman_ #1 _int } }
+ { \use:c { c__int_from_roman_ #1 _int } }
<
- { \use:c { c_int_from_roman_ #2 _int } }
+ { \use:c { c__int_from_roman_ #2 _int } }
{
- + \use:c { c_int_from_roman_ #2 _int }
- - \use:c { c_int_from_roman_ #1 _int }
- \int_from_roman_aux:NN
+ + \use:c { c__int_from_roman_ #2 _int }
+ - \use:c { c__int_from_roman_ #1 _int }
+ \__int_from_roman:NN
}
{
- + \use:c { c_int_from_roman_ #1 _int }
- \int_from_roman_aux:NN #2
+ + \use:c { c__int_from_roman_ #1 _int }
+ \__int_from_roman:NN #2
}
}
}
}
-\cs_new:Npn \int_from_roman_end:w #1 Q #2 \q_stop
+\cs_new:Npn \__int_from_roman_end:w #1 Q #2 \q_stop
{ \tl_if_empty:nTF {#2} {#1} {#2} }
-\cs_new:Npn \int_from_roman_clean_up:w #1 Q { + 0 Q -1 }
-\cs_new_eq:NN \int_show:N \kernel_register_show:N
-\cs_new_eq:NN \int_show:c \kernel_register_show:c
+\cs_new:Npn \__int_from_roman_clean_up:w #1 Q { + 0 Q -1 }
+\cs_new_eq:NN \int_show:N \__kernel_register_show:N
+\cs_new_eq:NN \int_show:c \__kernel_register_show:c
\cs_new_protected:Npn \int_show:n #1
- { \tex_showthe:D \int_eval:w #1 \int_eval_end: }
+ { \etex_showtokens:D \exp_after:wN { \int_use:N \__int_eval:w #1 } }
\int_const:Nn \c_one { 1 }
\int_const:Nn \c_two { 2 }
\int_const:Nn \c_three { 3 }
@@ -698,9 +759,13 @@
\int_const:Nn \c_max_int { 2 147 483 647 }
\int_new:N \l_tmpa_int
\int_new:N \l_tmpb_int
-\int_new:N \l_tmpc_int
\int_new:N \g_tmpa_int
\int_new:N \g_tmpb_int
+\cs_new_eq:NN \if_num:w \if_int_compare:w
+\int_new:N \l_tmpc_int
+\cs_new_eq:NN \int_eval:w \__int_eval:w
+\cs_new_eq:NN \int_eval_end: \__int_eval_end:
+\cs_new_eq:NN \int_value:w \__int_value:w
%%
%%
%% End of file `l3int.sty'.