summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua')
-rw-r--r--macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua b/macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua
new file mode 100644
index 0000000000..2cc56b6600
--- /dev/null
+++ b/macros/luatex/latex/luacas/tex/core/binaryoperation/difference.lua
@@ -0,0 +1,14 @@
+-- Seperates the various binary operations into their own files for readability
+
+--- Automatic simplification of difference expressions.
+--- @return BinaryOperation
+function BinaryOperation:simplifydifference()
+ local term1 = self.expressions[1]
+ local term2 = self.expressions[2]
+
+ if not term2 then
+ return BinaryOperation(BinaryOperation.MUL, {Integer(-1), term1}):autosimplify()
+ end
+
+ return BinaryOperation(BinaryOperation.ADD, {term1, BinaryOperation(BinaryOperation.MUL, {Integer(-1), term2}):autosimplify()}):autosimplify()
+end \ No newline at end of file