Class Range

All Implemented Interfaces:
PostfixMathCommandI, Serializable

public class Range extends BinaryFunction
A function which returns an increasing sequence of all the items between the end points inclusive.
 [1..10]
 
This is typically used with the RangeOperator and a modified parser such as ConfigurableParserWithRange.
  OperatorTable2 optab = new StandardOperatorTable2();
  Operator rangeOp = new RangeOperator("..", "[", "]", new Range(), Operator.BINARY+Operator.NOT_IN_PARSER);
  optab.insertOperator(OperatorTable2.SpecialOperators.RANGE , rangeOp, optab.getAssign());
  ConfigurableParser cp = new ConfigurableParserWithRange("..");
  Jep jep = new Jep(cp,optab);
Since:
Jep 4.1
See Also:
  • Constructor Details

    • Range

      public Range()
  • Method Details

    • eval

      public Object eval(Object l, Object r) throws EvaluationException
      Evaluate the function. The arguments should be numbers, and the result is a vector of all the numbers between the end points inclusive. Both end points are cast to ints, and rounded if necessary
      Specified by:
      eval in class BinaryFunction
      Parameters:
      l - the lower bound
      r - the upper bound
      Returns:
      a vector of Double values, or an empty vector if r < l.
      Throws:
      EvaluationException - if the function cannot be evaluated.