在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Keelar/ExprK开源软件地址(OpenSource Url):https://github.com/Keelar/ExprK开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):ExprKA simple mathematical expression evaluator for Kotlin and Java, written in Kotlin. Features:
Supported operatorsArithmetic operators
Logical operators
Pre-defined variables
Pre-defined functions
Examples:val result = Expressions()
.eval("(5+5)*10") // returns 100 You can define variables with the val result = Expressions()
.define("x", 5)
.eval("x*10") // returns 50 The define method returns the expression instance to allow chaining definition method calls together. val result = Expressions()
.define("x", 5)
.define("y", "5*2")
.eval("x*y") // returns 50 Variable definition expressions can reference previously defined variables. val result = Expressions()
.define("x", 5)
.define("y", "x^2")
.eval("y*x") // returns 125 You can add new functions with the val result = Expressions()
.addFunction("min") { arguments ->
if (arguments.isEmpty()) throw ExpressionException(
"min requires at least one argument")
arguments.min()!!
}
.eval("min(4, 8, 16)") // returns 4 You can set the precision and rounding mode with val result = Expressions()
.setPrecision(128)
.setRoundingMode(RoundingMode.UP)
.eval("222^3/5.5") |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论