We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以把常用的函数注册到引擎中,然后就能像内置函数一样在输入的数学表达式中使用。
e.g
engine.RegFunction("double", 1, func(expr ...engine.ExprAST) float64 { return engine.ExprASTResult(expr[0]) * 2 })
然后就可以在输入的表达式中使用这个函数 double:
double
exp := "double(6) + 2" r, err := engine.ParseAndExec("double(6) + 2") if err != nil { panic(err) } fmt.Printf("double(6) + 2 = %f\n", r) // will print : double(6) + 2 = 14.000000
The text was updated successfully, but these errors were encountered:
已实现.
Sorry, something went wrong.
update: 注册的函数名可以是英文字母和数字,但必须英文字母开头,且区分大小写。
使用该RegFunction函数注册时,能否不设置参数长度,或者能否允许我重复注册同一个函数
重复注册同名函数是不会被支持的。 对于可变参数的函数,暂时还不支持。后续会迭代这个需求,可以持续关注一下~
v3.3.0 增加对可选长度参数的自定义函数的注册支持
No branches or pull requests
可以把常用的函数注册到引擎中,然后就能像内置函数一样在输入的数学表达式中使用。
e.g
然后就可以在输入的表达式中使用这个函数
double
:The text was updated successfully, but these errors were encountered: