Class ChainedGeneralFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.extensions.chained.ChainedGeneralFunction
- All Implemented Interfaces:
ChainedFunctionI,DirtyFunction,JepComponent,PostfixMathCommandI,Serializable
public class ChainedGeneralFunction
extends PostfixMathCommand
implements ChainedFunctionI, JepComponent, DirtyFunction
Converts a general
PostfixMathCommandI so it can be used in a chain.
A nary function that takes n arguments is converted to an nary function with n-1 arguments.
These are Intermediate function that can be used in the middle of a chain as
[1..10] . F(5) . fold([x,y]=>x+y)
The apply(Evaluator, Node, Object) method will first
evaluate the child of the node then call the nary function f(x,y)
with the first argument from the child and the second argument from the chain.- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvaluate a chained function using an additional argument.booleancheckNumberOfParameters(int n) Checks the number of parameters of the function.Return a description of the function from the properties file.getInner()Gets a light-weight instance suitable for using in multiple threads.intReturn the required number of parameters.voidInitialize the component.voidsetCurNumberOfParameters(int n) Sets the number of current number of parameters used in the next call of run().Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, run, setDescription, setName, toString, toString
-
Constructor Details
-
ChainedGeneralFunction
-
-
Method Details
-
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.
-
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
-
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
-
apply
Description copied from interface:ChainedFunctionIEvaluate a chained function using an additional argument.- Specified by:
applyin interfaceChainedFunctionI- Parameters:
ev- the evaluatornode- top node of functionlhs- additional argument from previous element in the chain- Returns:
- Throws:
EvaluationException
-
init
Description copied from interface:JepComponentInitialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.- Specified by:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either a new instance, null or 'this'.
-
getInner
-
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 classPostfixMathCommand- Returns:
- the description of the function
-