aboutsummaryrefslogtreecommitdiff
path: root/src/math.lisp
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-12-05 15:50:16 +0200
committerSyndamia <kamen@syndamia.com>2022-12-05 15:50:26 +0200
commit851b8e44c410c5e8a86e924bf9c0666d02e66bed (patch)
treeee72fd0ccf82ab83d51bc94528dfc5d28886c2cb /src/math.lisp
parent804fc66a7afe0bde6365da84cb86daee4050bd62 (diff)
downloadsenzill-851b8e44c410c5e8a86e924bf9c0666d02e66bed.tar
senzill-851b8e44c410c5e8a86e924bf9c0666d02e66bed.tar.gz
senzill-851b8e44c410c5e8a86e924bf9c0666d02e66bed.zip
[math] Implemented op=, its derivatives and % macros
Diffstat (limited to 'src/math.lisp')
-rw-r--r--src/math.lisp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/math.lisp b/src/math.lisp
new file mode 100644
index 0000000..06931ff
--- /dev/null
+++ b/src/math.lisp
@@ -0,0 +1,33 @@
+(in-package senzill.math)
+
+(defmacro % (number divisor)
+ "Different name for the mod function"
+ `(mod ,number ,divisor))
+
+(defmacro op= (operation value &rest others)
+ "Executes operation on all values and stores result in first argument"
+ `(setf ,value (apply ,operation ,value ',others)))
+
+(defmacro += (value &rest numbers)
+ "Sums all numbers and stores result in name (first argument)"
+ `(op= '+ ,value ,@numbers))
+
+(defmacro ++_ (value)
+ "Adds increments value by one"
+ `(+= ,value 1))
+
+(defmacro -= (value &rest numbers)
+ "Adds all numbers and stores result in name (first argument)"
+ `(op= '- ,value ,@numbers))
+
+(defmacro -- (value)
+ "Decrements value by one"
+ `(-= ,value 1))
+
+(defmacro /= (value &rest numbers)
+ "Divides all numbers and stores result in name (first argument)"
+ `(op= '/ ,value ,@numbers))
+
+(defmacro *= (value &rest numbers)
+ "Multiplies all numbers and stores result in name (first argument)"
+ `(op= '* ,value ,@numbers))