class Lists {

  public static <X, Y> Y foldRight(Y initial, List<X> inputList, Aggregator<? super X, Y> op) {
    if (null == inputList || inputList.isEmpty()) {
      return initial;
    }

    Y next = initial;
    for (int i = inputList.size() - 1; i >= 0; i--) {
      X val = inputList.get(i);
      next = op.eval(val, next);
    }

    return next;
  }

  private  Lists();

}