Package com.singularsys.jep.functions
Class NaryFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NaryFunction
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
- Direct Known Subclasses:
Ele,FromBase,JepTest.AddFractionsNary,JepTest.MyNary,Mid,NullWrappedNary,NullWrappedNaryBinary,Round,RoundSF,Substring,ToBase
Convenient base class for nary functions.
Defines an
Object eval(Object[] args) method for calculating the result.- Author:
- Richard Morris
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionStandard constructor where any number of arguments is allowed.NaryFunction(int nArgs) Constructor where a fixed number of arguments is allowed -
Method Summary
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
Constructor Details
-
NaryFunction
public NaryFunction()Standard constructor where any number of arguments is allowed. Use the PostfixMathCommand.checkNumberOfParameters(int) method to restrict the number of arguments allowed. -
NaryFunction
public NaryFunction(int nArgs) Constructor where a fixed number of arguments is allowed- Parameters:
nArgs- number of arguments allowed
-
-
Method Details
-
run
Creates an array of object then callseval(Object[])- Specified by:
runin interfacePostfixMathCommandI- Overrides:
runin classPostfixMathCommand- Parameters:
stack- arguments for function- Throws:
EvaluationException- if function cannot be evaluated
-
eval
Evaluate the function- Parameters:
args- arguments to the function- Returns:
- value returned by the function
- Throws:
EvaluationException- if the calculation cannot be performed
-