Class Crunch

java.lang.Object
redempt.crunch.Crunch

public final class Crunch extends Object
Public API methods for compiling expressions
  • Method Details

    • compileExpression

      public static CompiledExpression compileExpression(String expression)
      Compiles a mathematical expression into a CompiledExpression. Variables must be integers starting at 1 prefixed with $. Supported operations can be found in BinaryOperator, which lists the operations and their symbols for use in expressions. Parenthesis are also supported.
      Parameters:
      expression - The expression to compile
      Returns:
      The compiled expression
    • compileExpression

      public static CompiledExpression compileExpression(String expression, ExpressionEnv env)
      Compiles a mathematical expression into a CompiledExpression. Variables must be integers starting at 1 prefixed with $. Supported operations can be found in BinaryOperator, which lists the operations and their symbols for use in expressions. Parenthesis are also supported.
      Parameters:
      expression - The expression to compile
      env - The EvaluationEnvironment providing custom functions that can be used in the expression
      Returns:
      The compiled expression
    • evaluateExpression

      public static double evaluateExpression(String expression, double... varValues)
      Compiles and evaluates an expression once. This is only for if you need a one-off evaluation of an expression which will not be evaluated again. If the expression will be evaluated multiple times, use compileExpression(String)
      Parameters:
      expression - The expression to evaluate
      varValues - The variable values for the expression
      Returns:
      The value of the expression