code: public static List<Pair> toPairs(List<Double> xyValues) {
          if (xyValues.size() % 2 != 0) {
              throw new RuntimeException(String.format("[discrete error] "
                      + "missing value in set of pairs (|xy|=%d)", xyValues.size()));
          }
          List<Pair> result = new ArrayList<Pair>((xyValues.size() + 1) / 2);
          Iterator<Double> it = xyValues.iterator();
          while (it.hasNext()) {
              result.add(new Pair(it.next(), it.next()));
          }
          return result;
      }
docs: Creates a list of Pair from a list of scalars given in the form
  
  `(x_1,y_1,...,x_n,y_n)`
  
  @param xyValues is a vector of fl::scalar given as
  `(x_1,y_1,...,x_n,y_n)`
  @return a list of Pair in the form
  `\left(\{x_1,y_1\},...,\{x_n,y_n\}\right)`
  @throws RuntimeException if a value is missing, that is, if the length of
  `xy` is odd: `|xy|\mod 2 = 1`