final LValue rawValue = sequence.nextRawValue();
if (rawValue == null)
{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
final TypeValuePair nextValue = rawValue.evaluate();
final Number number = typeRegistry.convertToNumber(nextValue.getType(), nextValue.getValue());
final BigDecimal next = NumberUtil.getAsBigDecimal(number);
if(last == null)
{
last = next;
}
else
{
if(last.compareTo(next) == 1)
{
last = next;
}
}
}
}
if(last == null)
{
throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
return new TypeValuePair(NumberType.GENERIC_NUMBER, last);
}