Package com.singularsys.jep.functions
Class NullaryFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.NullaryFunction
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
- Direct Known Subclasses:
ConstantFunction,JepTest.MyNullary,Random
Convenient base class for zero-argument nullary functions, like
random().
Defines an Object eval() method for calculating the result.- Since:
- 3.5
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Objecteval()Evaluate the functionstatic NullaryFunctioninstanceOf(Supplier<? super Object> fun) Create a NullaryFunction from a lambda expression.voidCallseval()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
-
NullaryFunction
public NullaryFunction()
-
-
Method Details
-
run
Callseval()- Specified by:
runin interfacePostfixMathCommandI- Overrides:
runin classPostfixMathCommand- Parameters:
stack- arguments for function- Throws:
EvaluationException- if function cannot be evaluated
-
eval
Evaluate the function- Returns:
- value of the function
- Throws:
EvaluationException- if some error at evaluation time
-
instanceOf
Create a NullaryFunction from a lambda expression. For exampleNullaryFunction.instanceOf(() -> Math.sqrt(2.0)- Parameters:
fun- the lambda function- Returns:
- a new NullaryFunction instance
- Since:
- Jep 4.0
-