Package redempt.crunch.functional
Class ExpressionEnv
java.lang.Object
redempt.crunch.functional.ExpressionEnv
- Direct Known Subclasses:
EvaluationEnvironment
Represents an environment containing functions that can be called in expressions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFunction(String name, int argCount, ToDoubleFunction<double[]> func) Adds a Function that can be called from expressions with this environmentaddFunction(Function function) Adds a Function that can be called from expressions with this environmentaddFunctions(Function... functions) Adds any number of Functions that can be called from expressions with this environmentaddLazyVariable(String name, DoubleSupplier supply) Adds a lazily-evaluated variable that will not need to be passed with the variable valuesintsetVariableNames(String... names)
-
Constructor Details
-
ExpressionEnv
public ExpressionEnv()Creates a new EvaluationEnvironment
-
-
Method Details
-
addFunction
Adds a Function that can be called from expressions with this environment- Parameters:
function- The function
-
addFunctions
Adds any number of Functions that can be called from expressions with this environment- Parameters:
functions- The functions to add
-
addLazyVariable
Adds a lazily-evaluated variable that will not need to be passed with the variable values- Parameters:
name- The name of the lazy variablesupply- A function to supply the value of the variable when needed
-
setVariableNames
-
addFunction
Adds a Function that can be called from expressions with this environment- Parameters:
name- The function nameargCount- The argument count for the functionfunc- The lambda to accept the arguments as a double array and return a value
-
getLeadingOperators
- Returns:
- The prefix tree of all leading operators, including unary operators and functions
-
getBinaryOperators
- Returns:
- The prefix tree of all binary operators
-
getValues
- Returns:
- The prefix tree of all values, including constants, variables, and lazy variables
-
getVariableCount
public int getVariableCount()- Returns:
- The number of variables in this expression environment
-