diff options
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 | 78 |
1 files changed, 78 insertions, 0 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 new file mode 100644 index 00000000000..fc962e950f8 --- /dev/null +++ b/Master/texmf-dist/tex/latex/lisp-on-tex/lisp-arith.sty @@ -0,0 +1,78 @@ +\newcount\@temp@inti +\newcount\@temp@intii +\addassoc\@globalenv\+{\@tlabel@func{\@temp@inti0\relax\@arith@plus}} +\def\@arith@plus#1#2#3{% + \ifx#2\relax + \let\@next@plus\@@arith@pm@fin + \else\ifx#2\@tlabel@int + \advance\@temp@inti#3\relax + \let\@next@plus\@arith@plus + \else + \errmessage{LISP on TeX [integer plus]: Invalid argument}% + \fi\fi\@next@plus#1} + +\addassoc\@globalenv\*{\@tlabel@func{\@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 + \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@minus#1#2#3#4#5{% + \@temp@inti#3\relax + \ifx#4\relax + \multiply\@temp@inti-1\relax + \let\@next@minus\@@arith@pm@fin + \else\ifx#4\@tlabel@int + \let\@next@minus\@@arith@minus + \fi\fi\@next@minus#1#4{#5}} + +\def\@@arith@minus#1#2#3{% + \ifx#2\relax + \let\@next@minus\@@arith@pm@fin + \else\ifx#2\@tlabel@int + \@temp@intii#3\relax % #3 < 0 + \advance\@temp@inti-\@temp@intii\relax + \let\@next@minus\@@arith@minus + \fi\fi\@next@minus#1} + + +\addassoc\@globalenv\/{\@tlabel@func{\@arith@div}} +\def\@arith@div#1#2#3#4#5{% + \@temp@inti#3\relax + \ifx#4\relax + \@temp@intii\@temp@inti\relax + \@temp@inti1\relax + \divide\@temp@inti\@temp@intii\relax + \let\@next@div\@@arith@pm@fin + \else\ifx#4\@tlabel@int + \let\@next@div\@@arith@div + \fi\fi\@next@div#1#4{#5}} + +\def\@@arith@div#1#2#3{% + \ifx#2\relax + \let\@next@div\@@arith@pm@fin + \else\ifx#2\@tlabel@int + \divide\@temp@inti#3\relax + \let\@next@div\@@arith@div + \fi\fi\@next@div#1} + +\addassoc\@globalenv\mod{\@tlabel@func{\@arith@mod}} +\def\@arith@mod#1\@tlabel@int#2\@tlabel@int#3{% + \@temp@intii#2\relax + \divide\@temp@intii#3\relax + \multiply\@temp@intii#3\relax + \@temp@inti#2\relax + \advance\@temp@inti-\@temp@intii + \@@arith@pm@fin#1} + +\addassoc\@globalenv\<{\@tlabel@func{\@arith@lt}} +\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}
\ No newline at end of file |