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:
  `CaseNonLazy`, `Ele`, `FromBase`, `GetOr`, `JepTest.AddFractionsNary`, `JepTest.MyNary`, `MakeMap`, `MapPfmc`, `MapPfmc.MapEntryPfmc`, `Mid`, `ModifiedParserTest.BadFun`, `NullWrappedNary`, `NullWrappedNaryBinary`, `NullWrapTest.MyNary`, `OverloadedNaryFunction`, `Put`, `Round`, `RoundSF`, `Substring`, `SwitchDefaultNonLazy`, `SwitchNonLazy`, `ToBase`

public abstract class NaryFunction extends PostfixMathCommand
Convenient base class for nary functions. Defines an `Object eval(Object[] args)` method for calculating the result.

Author:
  Richard Morris
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NaryFunction()`
  Standard constructor where any number of arguments is allowed.
  `NaryFunction(int nArgs)`
  Constructor where a fixed number of arguments is allowed

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract Object`
  `eval(Object[] args)`
  Evaluate the function
  `void`
  `run(Stack<Object> stack)`
  Creates an array of object then calls `eval(Object[])`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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

    public void run(Stack<Object> stack) throws EvaluationException
    Creates an array of object then calls `eval(Object[])`
    Specified by:
      `run` in interface `PostfixMathCommandI`
    Overrides:
      `run` in class `PostfixMathCommand`
    Parameters:
      `stack` - arguments for function
    Throws:
      `EvaluationException` - if function cannot be evaluated

  - ### eval

    public abstract Object eval(Object[] args) throws EvaluationException
    Evaluate the function
    Parameters:
      `args` - arguments to the function
    Returns:
      value returned by the function
    Throws:
      `EvaluationException` - if the calculation cannot be performed