diff options
author | Karl Berry <karl@freefriends.org> | 2015-10-25 22:26:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-10-25 22:26:36 +0000 |
commit | 2e5f14f60a516e247773eb44e16fdf71b24ffc6b (patch) | |
tree | dcf766a159ceb803ff37d6fc6093f14de9a57741 /Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty | |
parent | b21104f52f6a326c74adaf89be9b55745d4e65ba (diff) |
lisp-on-tex (25oct15)
git-svn-id: svn://tug.org/texlive/trunk@38706 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty index 23d48402873..1e4f622dbe1 100644 --- a/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty +++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty @@ -1,6 +1,7 @@ \newcount\@temp@inti \newcount\@temp@intii -\addassoc\@globalenv\+{\@tlabel@func{\@temp@inti0\relax\@arith@plus}} + +\@lisp@env@add@global\+{\@tlabel@func{\@lisp@func@check@args{*}{\@temp@inti0\relax\@arith@plus}}} \def\@arith@plus#1#2#3{% \ifx#2\relax \let\@next@plus\@@arith@pm@fin @@ -8,23 +9,30 @@ \advance\@temp@inti#3\relax \let\@next@plus\@arith@plus \else - \errmessage{LISP on TeX [integer plus]: Invalid argument}% + \let\@next@plus\@arith@type@error \fi\fi\@next@plus#1} -\addassoc\@globalenv\*{\@tlabel@func{\@temp@inti1\relax\@arith@mul}} +\@lisp@env@add@global\*{\@tlabel@func{\@lisp@func@check@args{*}{\@temp@inti1\relax\@arith@mul}}} \def\@arith@mul#1#2#3{% \ifx#2\relax \let\@next@mul\@@arith@pm@fin \else\ifx#2\@tlabel@int \multiply\@temp@inti#3\relax \let\@next@mul\@arith@mul + \else + \let\@next@mul\@arith@type@error \fi\fi\@next@mul#1} \def\@@arith@pm@fin#1{\expandafter\gdef \expandafter#1\expandafter{% \expandafter\@tlabel@int\expandafter{\the\@temp@inti}}} -\addassoc\@globalenv\-{\@tlabel@func{\@arith@minus}} +\def\@arith@type@error#1#2\relax{% notice #2 is dust + \gdef#1{\@tlabel@exception{{-1}% + {\@tlabel@string{arithmetical functions takes integer only.}}}}} + +\@lisp@env@add@global\-{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@minus}}} +%TODO: error handling of 1st argument \def\@arith@minus#1#2#3#4#5{% \@temp@inti#3\relax \ifx#4\relax @@ -32,6 +40,8 @@ \let\@next@minus\@@arith@pm@fin \else\ifx#4\@tlabel@int \let\@next@minus\@@arith@minus + \else + \let\@next@minus\@arith@type@error \fi\fi\@next@minus#1#4{#5}} \def\@@arith@minus#1#2#3{% @@ -41,10 +51,13 @@ \@temp@intii#3\relax % #3 < 0 \advance\@temp@inti-\@temp@intii\relax \let\@next@minus\@@arith@minus + \else + \let\@next@minus\@arith@type@error \fi\fi\@next@minus#1} -\addassoc\@globalenv\/{\@tlabel@func{\@arith@div}} +\@lisp@env@add@global\/{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@div}}} +%TODO: error handling of 1st argument \def\@arith@div#1#2#3#4#5{% \@temp@inti#3\relax \ifx#4\relax @@ -54,6 +67,8 @@ \let\@next@div\@@arith@pm@fin \else\ifx#4\@tlabel@int \let\@next@div\@@arith@div + \else + \let\@next@div\@arith@type@error \fi\fi\@next@div#1#4{#5}} \def\@@arith@div#1#2#3{% @@ -62,9 +77,12 @@ \else\ifx#2\@tlabel@int \divide\@temp@inti#3\relax \let\@next@div\@@arith@div + \else + \let\@next@div\@arith@type@error \fi\fi\@next@div#1} -\addassoc\@globalenv\mod{\@tlabel@func{\@arith@mod}} +\@lisp@env@add@global\mod{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@mod}}} +%TODO: error handling \def\@arith@mod#1\@tlabel@int#2\@tlabel@int#3{% \@temp@intii#2\relax \divide\@temp@intii#3\relax @@ -73,43 +91,50 @@ \advance\@temp@inti-\@temp@intii \@@arith@pm@fin#1} -\addassoc\@globalenv\<{\@tlabel@func{\@arith@lt}} +\@lisp@env@add@global\<{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@lt}}} +%TODO: error handling \def\@arith@lt#1\@tlabel@int#2\@tlabel@int#3{% \ifnum#2<#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi} -\addassoc\@globalenv\>{\@tlabel@func{\@arith@gt}} +\@lisp@env@add@global\>{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@gt}}} +%TODO: error handling \def\@arith@gt#1\@tlabel@int#2\@tlabel@int#3{% \ifnum#2>#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi} -\addassoc\@globalenv\leq{\@tlabel@func{\@arith@leq}} +\@lisp@env@add@global\leq{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@leq}}} +%TODO: error handling \def\@arith@leq#1\@tlabel@int#2\@tlabel@int#3{% \ifnum#2<#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi \ifnum#2=#3 \gdef#1{\@tlabel@bool{t}}\fi} -\addassoc\@globalenv\geq{\@tlabel@func{\@arith@geq}} +\@lisp@env@add@global\geq{\@tlabel@func{\@lisp@func@check@args{2}{\@arith@geq}}} +%TODO: error handling \def\@arith@geq#1\@tlabel@int#2\@tlabel@int#3{% \ifnum#2>#3 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi \ifnum#2=#3 \gdef#1{\@tlabel@bool{t}}\fi} -\addassoc\@globalenv\isZeroQ{\@tlabel@func{\@arith@is@zero}} +\@lisp@env@add@global\isZeroQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@zero}}} +%TODO: error handling \def\@arith@is@zero#1\@tlabel@int#2{% \ifnum#2=0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi} -\addassoc\@globalenv\positiveQ{\@tlabel@func{\@arith@is@positive}} +\@lisp@env@add@global\positiveQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@positive}}} +%TODO: error handling \def\@arith@is@positive#1\@tlabel@int#2{% \ifnum#2>0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi} -\addassoc\@globalenv\negativeQ{\@tlabel@func{\@arith@is@negative}} -\def\@arith@is@positive#1\@tlabel@int#2{% +\@lisp@env@add@global\negativeQ{\@tlabel@func{\@lisp@func@check@args{1}{\@arith@is@negative}}} +%TODO: error handling +\def\@arith@is@negative#1\@tlabel@int#2{% \ifnum#2<0 \gdef#1{\@tlabel@bool{t}}\else\gdef#1{\@tlabel@bool{f}}\fi} -\addassoc\@globalenv\max{\@tlabel@func{\@arith@max}} +\@lisp@env@add@global\max{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@max}}} \def\@arith@max#1#2#3{% \ifx#2\@tlabel@int \@temp@inti#3\relax \let\@next@max\@@arith@max \else - \errmessage{LISP on TeX [integer max]: Invalid argument or Too few arguments}% + \let\@next@max\@arith@type@error \fi\@next@max#1} \def\@@arith@max#1#2#3{% \ifx#2\relax @@ -118,16 +143,16 @@ \ifnum#3>\@temp@inti\@temp@inti#3\relax\fi \let\@next@max\@@arith@max \else - \errmessage{LISP on TeX [integer max]: Invalid argument}% + \let\@next@max\@arith@type@error \fi\fi\@next@max#1} -\addassoc\@globalenv\min{\@tlabel@func{\@arith@min}} +\@lisp@env@add@global\min{\@tlabel@func{\@lisp@func@check@args{+}{\@arith@min}}} \def\@arith@min#1#2#3{% \ifx#2\@tlabel@int \@temp@inti#3\relax \let\@next@min\@@arith@min \else - \errmessage{LISP on TeX [integer min]: Invalid argument or Too few arguments}% + \let\@next@min\@arith@type@error \fi\@next@min#1} \def\@@arith@min#1#2#3{% \ifx#2\relax @@ -136,5 +161,5 @@ \ifnum#3<\@temp@inti\@temp@inti#3\relax\fi \let\@next@min\@@arith@min \else - \errmessage{LISP on TeX [integer min]: Invalid argument}% + \let\@next@min\@arith@type@error \fi\fi\@next@min#1} |