summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/expl3/l3int.dtx
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-29 11:23:34 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-29 11:23:34 +0000
commitef285e6a49a93af098150d0b3125a34d3477ba55 (patch)
tree124a55595390d358e0cda8ae26f78e9a263e9a21 /Master/texmf-dist/source/latex/expl3/l3int.dtx
parente7477f362711cc9d05dfa1ee71301fb34cce2d94 (diff)
expl3 update (2008/06/20)
git-svn-id: svn://tug.org/texlive/trunk@9869 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3int.dtx')
-rw-r--r--Master/texmf-dist/source/latex/expl3/l3int.dtx140
1 files changed, 109 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3int.dtx b/Master/texmf-dist/source/latex/expl3/l3int.dtx
index f4e582ec12f..ccc30e7dd83 100644
--- a/Master/texmf-dist/source/latex/expl3/l3int.dtx
+++ b/Master/texmf-dist/source/latex/expl3/l3int.dtx
@@ -32,26 +32,21 @@
%%
%% -----------------------------------------------------------------------
%
-%<package>\RequirePackage{l3names}
-%<*dtx>
+%<*driver|package>
+\RequirePackage{l3names}
+%</driver|package>
%\fi
-\def\GetIdInfo$Id: #1.dtx #2 #3-#4-#5 #6 #7$#8{%
- \def\fileversion{#2}%
- \def\filedate{#3/#4/#5}%
- \ProvidesFile{#1.dtx}[#3/#4/#5 v#2 #8]%
-}
-%\iffalse
-%</dtx>
-%\fi
-\GetIdInfo$Id: l3int.dtx 573 2006-08-21 20:59:37Z morten $
+\GetIdInfo$Id: l3int.dtx 702 2007-11-27 14:21:49Z morten $
{L3 Experimental Integer module}
-%
-% \iffalse
+%\iffalse
%<*driver>
+%\fi
+\ProvidesFile{\filename.\filenameext}
+ [\filedate\space v\fileversion\space\filedescription]
+%\iffalse
\documentclass{l3doc}
-
\begin{document}
-\DocInput{l3int.dtx}
+\DocInput{\filename.\filenameext}
\end{document}
%</driver>
% \fi
@@ -99,6 +94,7 @@
%
% \begin{function}{%
% \int_incr:N |
+% \int_incr:c |
% \int_gincr:N |
% \int_gincr:c |
% }
@@ -111,6 +107,7 @@
%
% \begin{function}{%
% \int_decr:N |
+% \int_decr:c |
% \int_gdecr:N |
% \int_gdecr:c |
% }
@@ -154,6 +151,7 @@
% \int_add:Nn |
% \int_add:cn |
% \int_gadd:Nn |
+% \int_gadd:cn |
% }
% \begin{syntax}
% "\int_add:Nn" <int> "{" <integer expr> "}"
@@ -165,7 +163,9 @@
%
% \begin{function}{%
% \int_sub:Nn |
+% \int_sub:cn |
% \int_gsub:Nn |
+% \int_gsub:cn |
% }
% \begin{syntax}
% "\int_gsub:Nn" <int> "{" <integer expr> "}"
@@ -356,6 +356,25 @@
% \end{function}
%
% \begin{function}{%
+% \int_max_of:nn |
+% \int_min_of:nn |
+% }
+% \begin{syntax}
+% "\int_max_of:nn" "{"<int~expr>"}" "{"<int~expr>"}"
+% \end{syntax}
+% Return the largest or smallest of two integer expressions.
+% \end{function}
+%
+% \begin{function}{%
+% \int_abs:n |
+% }
+% \begin{syntax}
+% "\int_abs:n" "{"<int~expr>"}"
+% \end{syntax}
+% Return the numerical value of an integer expression.
+% \end{function}
+%
+% \begin{function}{%
% \int_if_odd:nTF |
% \int_if_odd_p:n |
% }
@@ -419,6 +438,8 @@
%
% We start by ensuring that the required packages are loaded.
% \begin{macrocode}
+%<package>\ProvidesExplPackage
+%<package> {\filename}{\filedate}{\fileversion}{\filedescription}
%<package&!check>\RequirePackage{l3num}
%<package&check>\RequirePackage{l3chk}
%<*initex|package>
@@ -443,6 +464,10 @@
% \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}
% Incrementing and decrementing of integer registers is done with
% the following functions.
% \begin{macrocode}
@@ -485,11 +510,19 @@
\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}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\int_new:N}
@@ -556,8 +589,11 @@
% \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}
% Adding and substracting to and from a counter \ldots
% We should think of using these functions
% \begin{macrocode}
@@ -591,12 +627,18 @@
%</check>
%<-check> \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}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\int_use:N}
@@ -610,15 +652,6 @@
% \end{macro}
%
%
-% \begin{macro}{\int_gincr:c}
-% \begin{macro}{\int_gdecr:c}
-% We also need \ldots
-% \begin{macrocode}
-\def_new:Npn \int_gincr:c {\exp_args:Nc \int_gincr:N}
-\def_new:Npn \int_gdecr:c {\exp_args:Nc \int_gdecr:N}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
%
%
% \begin{macro}{\int_to_arabic:n}
@@ -782,7 +815,7 @@
% Turning a number into a symbol is also easy enough.
% \begin{macrocode}
\def_new:Npn \int_to_symbol:n #1{
- \mode_math:TF
+ \mode_if_math:TF
{
\int_convert_number_with_rule:nnN {#1}{9}
\int_symbol_math_conversion_rule:n
@@ -896,8 +929,38 @@
\def_new:Npn \int_div_truncate:nn {
\int_pre_eval_two_args:Nnn\int_div_truncate_raw:nn
}
+% \end{macrocode}
+% Initial version didn't work correctly with e\TeX's implementation.
+% \begin{macrocode}
+%\def_new:Npn \int_div_truncate_raw:nn #1#2 {
+% \int_eval:n{ (2*#1 - #2) / (2* #2) }
+%}
+% \end{macrocode}
+% New version by Heiko:
+% \begin{macrocode}
\def_new:Npn \int_div_truncate_raw:nn #1#2 {
- \int_eval:n{ (2*#1 - #2) / (2* #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)
+ \scan_stop:
}
% \end{macrocode}
% For the sake of completeness:
@@ -935,6 +998,20 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\int_max_of:nn}
+% \begin{macro}{\int_min_of:nn}
+% \begin{macro}{\int_abs:n}
+% Simple comparison tests.
+% \begin{macrocode}
+\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
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
% \begin{macro}{\int_compare_p:nNn}
% A predicate function.
% \begin{macrocode}
@@ -968,18 +1045,19 @@
% \begin{macro}{\int_dowhile:nNnF}
% These are quite easy given the above functions. The "while" versions
% test first and then execute the body. The "dowhile" does it the
-% other way round.
+% other way round. The have to be defined as ``long'' since the "T" argument
+% might contain "\par" tokens.
% \begin{macrocode}
-\def_new:Npn \int_whiledo:nNnT #1#2#3#4{
+\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_new:Npn \int_whiledo:nNnF #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_new:Npn \int_dowhile:nNnT #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_new:Npn \int_dowhile:nNnF #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}}
}
% \end{macrocode}