Class Function

java.lang.Object
redempt.crunch.functional.Function
All Implemented Interfaces:
Token

public class Function extends Object implements Token
Represents a function which can be called in expressions whose environments have it
  • Constructor Details

    • Function

      public Function(String name, int argCount, ToDoubleFunction<double[]> function)
      Create a Function
      Parameters:
      name - The function name
      argCount - The number of arguments this Function will take
      function - A lambda to take the arguments as a double array and return a value
  • Method Details

    • getName

      public String getName()
      Returns:
      The name of this function
    • getArgCount

      public int getArgCount()
      Returns:
      The number of arguments this function takes
    • call

      public double call(double[] values)
      Calls this function with a set of values - Warning, no validation is done on array size
      Parameters:
      values - The input values
      Returns:
      The output value
    • getType

      public TokenType getType()
      Specified by:
      getType in interface Token
      Returns:
      The type of this Token