Class EvaluationEnvironment

java.lang.Object
redempt.crunch.functional.EvaluationEnvironment

public class EvaluationEnvironment extends Object
Represents an environment containing functions that can be called in expressions
  • Constructor Details

    • EvaluationEnvironment

      public EvaluationEnvironment()
      Creates a new EvaluationEnvironment
  • Method Details

    • addFunction

      public void addFunction(Function function)
      Adds a Function that can be called from expressions with this environment
      Parameters:
      function - The function
    • addFunctions

      public void addFunctions(Function... functions)
      Adds any number of Functions that can be called from expressions with this environment
      Parameters:
      functions - The functions to add
    • addLazyVariable

      public void addLazyVariable(String name, DoubleSupplier supply)
      Adds a lazily-evaluated variable that will not need to be passed with the variable values
      Parameters:
      name - The name of the lazy variable
      supply - A function to supply the value of the variable when needed
    • setVariableNames

      public void setVariableNames(String... names)
    • addFunction

      public void addFunction(String name, int argCount, ToDoubleFunction<double[]> func)
      Adds a Function that can be called from expressions with this environment
      Parameters:
      name - The function name
      argCount - The argument count for the function
      func - The lambda to accept the arguments as a double array and return a value
    • clearFunctions

      public void clearFunctions()
      Removes all functions
    • getNamedTokens

      public CharTree<Token> getNamedTokens()