summaryrefslogtreecommitdiff
path: root/tex/context/base/x-calcmath.mkiv
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
committerMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
commit85b7bc695629926641c7cb752fd478adfdf374f3 (patch)
tree80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/x-calcmath.mkiv
downloadcontext-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/x-calcmath.mkiv')
-rw-r--r--tex/context/base/x-calcmath.mkiv87
1 files changed, 87 insertions, 0 deletions
diff --git a/tex/context/base/x-calcmath.mkiv b/tex/context/base/x-calcmath.mkiv
new file mode 100644
index 000000000..c726843fa
--- /dev/null
+++ b/tex/context/base/x-calcmath.mkiv
@@ -0,0 +1,87 @@
+%D \module
+%D [ file=m-calcmath,
+%D version=2006.04.24, % 1999.11.06,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Calculator Math,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D Lua code.
+
+\ctxloadluafile{x-calcmath}{}
+
+%D Interface:
+
+\unprotect
+
+\def\inlinecalcmath #1{\mathematics{\ctxlua{calcmath.tex("#1",1)}}}
+\def\displaycalcmath#1{\startformula\ctxlua{calcmath.tex("#1",2)}\stopformula}
+
+\let\calcmath\inlinecalcmath
+
+\let\icm\inlinecalcmath
+\let\dcm\displaycalcmath
+
+\startxmlsetups xml:cam:define
+ \xmlsetsetup {\xmldocument} {cam:*} {*}
+ \xmlsetsetup {\xmldocument} {(icm|dcm)} {cam:*}
+\stopxmlsetups
+
+\xmlregisterns{cam}{calcmath}
+
+\xmlregistersetup{xml:cam:define}
+
+% tex -> lua -> tex -> lua -> tex
+% \mathematics{\ctxlua{calcmath.xml(\!!bs\xmlflush{#1}\!!es,1)}}
+% tex -> lua -> tex
+% \mathematics{\ctxlua{calcmath.xml("#1",1)}}%
+
+\startxmlsetups cam:i
+ \mathematics{\ctxlua{calcmath.xml("#1",1)}}%
+\stopxmlsetups
+
+\startxmlsetups cam:d
+ \startformula\ctxlua{calcmath.xml("#1",2)}\stopformula
+\stopxmlsetups
+
+\startxmlsetups cam:icm
+ \mathematics{\ctxlua{calcmath.xml("#1",1)}}
+\stopxmlsetups
+
+\startxmlsetups cam:dcm
+ \startformula\ctxlua{calcmath.xml("#1",2)}\stopformula
+\stopxmlsetups
+
+\protect \endinput
+
+\starttext
+
+% \calcmath{sin(x) + x^2 + x^(1+x) + 1/x^2 + mean(x+mean(y))}
+% \calcmath{int(a,b,c)}
+% \calcmath{(1+x)/(1+x) + (1+x)/(1+(1+x)/(1+x))}
+% \calcmath{10E-2}
+% \calcmath{(1+x)/x}
+% \calcmath{(1+x)/12}
+% \calcmath{(1+x)/-12}
+% \calcmath{1/-12}
+% \calcmath{12x/(1+x)}
+% \calcmath{exp(x+exp(x+1))}
+% \calcmath{abs(x+abs(x+1)) + pi + inf}
+% \calcmath{Dx Dy}
+% \calcmath{D(x+D(y))}
+% \calcmath{Df(x)}
+% \calcmath{g(x)}
+
+\calcmath{sqrt(sin^2(x)+cos^2(x))}
+
+\startXMLdata
+test <icm>sqrt(sin^2(x)+cos^2(x))</icm> test
+test <dcm>sqrt(sin^2(x)+cos^2(x))</dcm> test
+\stopXMLdata
+
+\stoptext