Class LambdaFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.misc.MacroFunction
com.singularsys.extensions.lambda.LambdaFunction
- All Implemented Interfaces:
JepComponent,PostfixMathCommandI,Serializable
PostfixMathCommand representing a lambda functions.
These are typically created by the
LambdaFunGenerator.- Since:
- Extensions 2.1
- See Also:
-
Field Summary
FieldsFields inherited from class com.singularsys.jep.misc.MacroFunction
ev, expression, jep, nf, preCompiled, sv, topNode, varNames, varsFields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckNumberOfParameters(int n) Checks the number of parameters of the function.Return a description of the function from the properties file.Returns a new copy of the function, uses theMacroFunction(String, String[], String, Node)constructor.intReturn the required number of parameters.Get the signature of the functionvoidInitialise the LambdaFunction.voidCalculates the value of the expression.voidsetCurNumberOfParameters(int n) Sets the number of current number of parameters used in the next call of run().voidRename the function.toString()Prints the function in the form[x,y]=>x^2+y^2Methods inherited from class com.singularsys.jep.misc.MacroFunction
getParameterNames, getTopNode, getVarsMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, setDescription, toString
-
Field Details
-
DEBUG
public static boolean DEBUG
-
-
Constructor Details
-
LambdaFunction
public LambdaFunction(String funName, String[] parameters, String expression, Node root, Signature sig) Create a lambda function from a node tree. Theinit(Jep)method must be called to compile the expression.- Parameters:
funName- function nameparameters- list of parametersexpression- string representation of equationroot- root of expressions tree.sig-- See Also:
-
-
Method Details
-
getNumberOfParameters
public int getNumberOfParameters()Description copied from class:PostfixMathCommandReturn the required number of parameters.- Specified by:
getNumberOfParametersin interfacePostfixMathCommandI- Overrides:
getNumberOfParametersin classPostfixMathCommand- Returns:
- allowable number of parameters, -1 if a variable number is allowed
-
checkNumberOfParameters
public boolean checkNumberOfParameters(int n) Description copied from class:PostfixMathCommandChecks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method- Specified by:
checkNumberOfParametersin interfacePostfixMathCommandI- Overrides:
checkNumberOfParametersin classPostfixMathCommand- Parameters:
n- number of parameters function will be called with.- Returns:
- false if an illegal number of parameters is supplied, true otherwise.
-
setCurNumberOfParameters
public void setCurNumberOfParameters(int n) Description copied from class:PostfixMathCommandSets the number of current number of parameters used in the next call of run(). This method is only called when the reqNumberOfParameters is -1.- Specified by:
setCurNumberOfParametersin interfacePostfixMathCommandI- Overrides:
setCurNumberOfParametersin classPostfixMathCommand- Parameters:
n- number of parameter for next call of function
-
run
Description copied from class:MacroFunctionCalculates the value of the expression.- Specified by:
runin interfacePostfixMathCommandI- Overrides:
runin classMacroFunction- Parameters:
stack- arguments for function- Throws:
EvaluationException- if the calculation cannot be performed
-
init
Initialise the LambdaFunction. As well as performing the actions inMacroFunction.init(Jep)it searches for any nested lambda functions and complies those.- Specified by:
initin interfaceJepComponent- Overrides:
initin classMacroFunction- Parameters:
j- Jep instance
-
setName
Rename the function. Also changes the names of variables for this lambda function and any nested lambda functions.- Specified by:
setNamein interfacePostfixMathCommandI- Overrides:
setNamein classMacroFunction- Parameters:
newName- new name for the function
-
toString
Prints the function in the form[x,y]=>x^2+y^2- Overrides:
toStringin classMacroFunction
-
getLightWeightInstance
Description copied from class:MacroFunctionReturns a new copy of the function, uses theMacroFunction(String, String[], String, Node)constructor.- Specified by:
getLightWeightInstancein interfaceJepComponent- Overrides:
getLightWeightInstancein classMacroFunction- Returns:
- either a new instance, null or 'this'.
-
getDescription
Description copied from class:PostfixMathCommandReturn a description of the function from the properties file. The property name is the class name followed by ".description". The property is found using theJepMessagesclass, which can be configured to add additional properties files. IfPostfixMathCommand.setDescription(String)has been called, return the description set by that method instead.- Specified by:
getDescriptionin interfacePostfixMathCommandI- Overrides:
getDescriptionin classMacroFunction- Returns:
- the description of the function
-
getSignature
Get the signature of the function- Returns:
- the signature
-