Class Expression

java.lang.Object
com.sk89q.worldedit.internal.expression.Expression
All Implemented Interfaces:
Cloneable

public class Expression extends Object implements Cloneable
Compiles and evaluates expressions.

Supported operators:

  • Logical: &&, ||, ! (unary)
  • Bitwise: ~ (unary), >>, <<
  • Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)
  • Comparison: <=, >=, >, <, ==, !=, ~= (near)

Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh, exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh, sqrt, tan, tanh and more. (See the Functions class or the wiki)

Constants: e, pi

To compile an equation, run Expression.compile("expression here", "var1", "var2"...). If you wish to run the equation multiple times, you can then optimize it, by calling optimize(). You can then run the equation as many times as you want by calling evaluate(double...). You do not need to pass values for all slots specified while compiling. To query slots after evaluation, you can use the slot table.