|
@@ -0,0 +1,18 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/dengsgo/math-engine/engine"
|
|
|
+ "math"
|
|
|
+)
|
|
|
+
|
|
|
+func init() {
|
|
|
+ engine.RegFunction("log", 2, func(expr ...engine.ExprAST) float64 {
|
|
|
+ base := math.Log(engine.ExprASTResult(expr[0]))
|
|
|
+ number := math.Log(engine.ExprASTResult(expr[1]))
|
|
|
+ return number / base
|
|
|
+ })
|
|
|
+
|
|
|
+ engine.RegFunction("ln", 1, func(expr ...engine.ExprAST) float64 {
|
|
|
+ return math.Log(engine.ExprASTResult(expr[0]))
|
|
|
+ })
|
|
|
+}
|